I am having some problems getting matplotlib.dates.datestr2num to handle
timezones in the datestring.
import matplotlib
matplotlib.dates.datestr2num('Jan 1, 2007 12:00 PDT')
732677.83333333337
matplotlib.dates.datestr2num('Jan 1, 2007 12:00 PST')
732677.83333333337
matplotlib.dates.datestr2num('Jan 1, 2007 12:00-08')
732677.83333333337
matplotlib.dates.datestr2num('Jan 1, 2007 12:00 UTC')
732677.5
matplotlib.dates.datestr2num('Jan 1, 2007 12:00 EST')
732677.5
matplotlib.dates.datestr2num('Jan 1, 2007 12:00-07')
732677.79166666663
The problem appears to lie with dateutil, as direct use of the
dateutil.parser.parse function shows the same problem:
import dateutil.parser
dateutil.parser.parse('Jan 1, 2007 12:00 EST')
datetime.datetime(2007, 1, 1, 12, 0)
dateutil.parser.parse('Jan 1, 2007 12:00 PDT')
datetime.datetime(2007, 1, 1, 12, 0, tzinfo=tzlocal())
dateutil.parser.parse('Jan 1, 2007 12:00 PST')
datetime.datetime(2007, 1, 1, 12, 0, tzinfo=tzlocal())
I am using dateutil version 1.2.
Any suggestions on how to get either matplotlib.dates.datestr2num or
dateutil.parser.parse to properly handle timezone information in the
datestring would be greatly appreciated.
Charles Seaton
OHSU/CMOP
···
--
View this message in context: http://www.nabble.com/datestr2num%2C-dateutil.parse-and-timezone-problems-tf4609462.html#a13162968
Sent from the matplotlib - users mailing list archive at Nabble.com.