parsing times like "5 minutes ago"?
Paul McGuire
ptmcg at austin.rr.com
Tue Jul 7 02:02:44 EDT 2009
On Jul 6, 7:21 pm, m... at pixar.com wrote:
> I'm looking for something like Tcl's [clock scan] command which parses
> human-readable time strings such as:
>
> % clock scan "5 minutes ago"
> 1246925569
> % clock scan "tomorrow 12:00"
> 1246993200
> % clock scan "today + 1 fortnight"
> 1248135628
>
> Does any such package exist for Python?
>
> Many TIA!
> Mark
>
> --
> Mark Harrison
> Pixar Animation Studios
I've been dabbling with such a parser with pyparsing - here is my
progress so far: http://pyparsing.wikispaces.com/UnderDevelopment
It parses these test cases:
today
tomorrow
yesterday
in a couple of days
a couple of days from now
a couple of days from today
in a day
3 days ago
3 days from now
a day ago
now
10 minutes ago
10 minutes from now
in 10 minutes
in a minute
in a couple of minutes
20 seconds ago
in 30 seconds
20 seconds before noon
20 seconds before noon tomorrow
noon
midnight
noon tomorrow
-- Paul
More information about the Python-list
mailing list