[Zope3-dev] Re: [Python-Dev] Holes in time
Guido van Rossum
guido@python.org
Fri, 03 Jan 2003 19:05:38 -0500
> I was working on a possible solution when I stumbled across the fact
> that the current tzinfo documentation doesn't seem to specify whether
> the dst() method expects the "dt" argument to be in terms of UTC or
> local time. Sometimes when working on the problem I assumed dt was in
> UTC, making the conversion from UTC to local time easy, and at other
> times I assumed dt was in local time, making the conversion from local
> time to UTC easy. Which is it?
Local time. This is the source of most problems!
> Once that's decided, it seems like the "hard" case (whichever is the
> hard one) could be solved by first computing the UTC offset at the time
> requested, then computing the UTC offset at a time adjusted by the
> offset. If the two computed offsets are different, you know you've
> straddled a daylight savings boundary, and maybe the second offset is
> the correct offset. That's just a guess.
You're slowly rediscovering the guts of datetimetz.astimezone(). Have
a look at the python code in
python/nondist/sandbox/datetime/dateyime.py before you go any
further. :-)
--Guido van Rossum (home page: http://www.python.org/~guido/)