[Datetime-SIG] PEP 495 (Local Time Disambiguation) is ready for pronouncement

Carl Meyer carl at oddbird.net
Tue Aug 18 21:31:49 CEST 2015

Hi Tim,

On 08/18/2015 12:42 PM, Tim Peters wrote:
> But I'd still name it "_later" instead.  It's an implementation detail
> required to make some obscure edge cases work right "by magic" far
> more than an advertised feature users need to worry about (or even be
> aware of).  tzinfo authors need to be acutely aware of it, but since
> silence implies assent I take it we all agree now there are only 2 of
> those ;-)

I'm not a tzinfo author. I recently wrote a scheduling system (using
datetime and pytz), and I made use of pytz's roughly-equivalent `is_dst`
flag in order to detect gaps and folds in a weekly calendar displayed to
the user in local time, so as to (more or less) gracefully prevent the
scheduling of appointments in a nonexistent hour, even though for
visual/layout reasons the nonexistent hour still has to appear on the
calendar. [1] So I'm not sure it's true that this is a flag that only
tzinfo authors will have use for.

That experience is also why I wish PEP 495 had a nicer way to check for
ambiguous/missing times. That project did a _ton_ of "construct naive
datetime by combining date and time, then convert that naive datetime to
a local timezone, raising an error if the resulting local time is
missing or ambiguous." That was trivial with the pytz API: if you
specify `tz.localize(naive_dt, is_dst=None)` you'll get an exception on
an ambiguous or missing result. It sounds less fun with PEP 495 (would
just require a wrapper function to do the conversions, so not too bad --
just feels wrong to do all the conversions twice, when internally
datetime should be able to know enough to just raise the exception I
want right away).


[1] Fun sidenote: Google Calendar, last I checked, completely fails to
handle this gracefully. If you try to schedule an event in the
nonexistent hour, the UI allows you to proceed, and then you get an
opaque "Unknown error" message.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150818/7f226875/attachment.sig>

More information about the Datetime-SIG mailing list