# [Python-Dev] Status on PEP-431 Timezones

Alexander Belopolsky alexander.belopolsky at gmail.com
Sat Jul 25 04:13:55 CEST 2015

```On Fri, Jul 24, 2015 at 9:39 PM, Tim Peters <tim.peters at gmail.com> wrote:

> > But IIUC what Lennart is complaining about
>
> I don't, and I wish he would be more explicit about what "the
> problem(s)" is(are).
>
> > is the fact that the DST flag isn't part of and can't be embedded into a
> local time,
> > so it's impossible to fold the second parameter to \$fromlocal\$ into
> \$t\$.  Without
> > that, a local time isn't rich enough to designate a single point in time
> and the
> > whole edifice breaks.
>
> You can blame Guido for that too ;-) , but in this case I disagree(d)
> with him:  Guido was overly (IMO) annoyed by that the only apparent
> purpose for a struct tm's tm_ isdst flag was to disambiguate local
> times in a relative handful of cases.  His thought:  an entire bit
> just for that?!  My thought:  get over it, it's one measly bit.

IIUC, Lennart came to (a wrong IMHO) conclusion that one bit is not enough
and you
must either keep datetime in UTC or store the UTC offset with datetime.

My position is that one bit is enough to disambiguate local time in all
sane situations,
but the name "isdst" is misleading because discontinuities in UTC to Local
function
(from now on called L(t)) may be due to causes other than DST transitions.

The math here is very simple: there are two kinds of discontinuities: you
either move the
local clock forward by a certain amount or you move it back.  Let's call
these (unimaginatively)
discontinuities of the first and second kind.

When you have a discontinuity of the first kind, you have a range of values
u for which
the equation u = L(t) has no solution for t.  However, if we linearly
extrapolate L(t) from  before
the discontinuity forward, we get a linear function Lb(t) and we can solve
u = Lb(t) for any
value of u.  The problem, however is that we can also extend L(t) linearly
from the time
after the discontinuity to all times and get another function La(t) which
will also allow you to
solve equation u = La(t) for all times.  Without user input, there is no
way to tell which solution
she expects.  This is the 1-bit of information that we need.

The situation with the discontinuity of the second kind is similar, but
even simpler.  Here,
u = L(t) has two solutions and we need 1-bit of information to disambiguate.
-------------- next part --------------
An HTML attachment was scrubbed...