Jim Carroll wrote: > M.-A. Lemburg <mal <at> egenix.com> writes: > >> On 2008-03-07 22:24, Jim Carroll wrote: >>> It's taken me a couple of hours to give up on strptime >>> with %Z for recognizing >>> time zones... but that still leaves me in the wrong zone: >>> >>> How can I use the "PST" (or any other time zone name) >>> to adjust dt by the >>> correct number of hours to get it into UTC before storing in MySQL? >> You could try mxDateTime's parser. It will convert most timezones >> into UTC for you: >> >> >>> from mx.DateTime import * >> >>> DateTimeFrom('10:29:52 PST, Feb 29, 2008') >> <mx.DateTime.DateTime object for '2008-02-29 18:29:52. >> 00' at 2afdc7078f50> >> > > Unfortunately, mx.DateTime also ignores the time zone. If > I parse the PST time, and ask for the result's time zone it > gives me my local time zone.
The result of the mxDateTime parser will always be UTC, if you provide a time zone. You can then convert this value to any other timezone you choose. The reason for this is simple: UTC is the only stable timezone you can use if you want to store date/time value in e.g. a database or file. -- Marc-Andre Lemburg eGenix.com Professional Python Software directly from the Source (#1, Aug 10 2003) >>> Python/Zope Products & Consulting ... http://www.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ -- http://mail.python.org/mailman/listinfo/python-list