% 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
If you're on a machine with GNU datethe simplest solution is to use it
to parse the string.
Q&D:
def clock_scan(datestring):
stdout,stderr = subprocess.Popen(
['date','+%s','--date=%s' % datestring ],
stdout=subprocess.PIPE).communicate()
return float(stdout)
clock_scan('1 hour ago')
clock_scan('next week')
Carl Banks
The timelib module might do what you want
http://pypi.python.org/pypi/timelib/0.2
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
Is this only for English times or is I18N a concern?
Stefan