You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I have trouble obtaining UTC based data from Calendar.parseDT. I tried making things work by adding sourceTime=datetime.utcnow() and it seemed fine for a while.
Parsing "at 9:30" however leads to 9:30 in UTC without adjusting for the time difference.
Consider the following.
from datetime import datetime
import parsedatetime as pdt
import sys
import pytz
def parse_args(argv=sys.argv):
cal = pdt.Calendar()
timestr = ' '.join(argv)
ret = cal.parseDT(timestr, sourceTime=datetime.utcnow(), tzinfo=pytz.utc)[0]
print(ret)
if __name__ == '__main__':
parse_args()
Command line:
C:\dvl\tim>python pdt_test.py now
2015-06-26 04:57:06+00:00
C:\dvl\tim>python pdt_test.py in 10 min
2015-06-26 05:07:10+00:00
C:\dvl\tim>python pdt_test.py at 12:50
2015-06-26 12:50:00+00:00
I'd expect (or would like) the last output to be 4:50 UTC. Any advice?
Best regards,
Matthias
The text was updated successfully, but these errors were encountered:
Hi,
I have trouble obtaining UTC based data from Calendar.parseDT. I tried making things work by adding sourceTime=datetime.utcnow() and it seemed fine for a while.
Parsing "at 9:30" however leads to 9:30 in UTC without adjusting for the time difference.
Consider the following.
Command line:
I'd expect (or would like) the last output to be 4:50 UTC. Any advice?
Best regards,
Matthias
The text was updated successfully, but these errors were encountered: