[Datetime-SIG] Another round on error-checking

Alexander Belopolsky alexander.belopolsky at gmail.com
Mon Aug 31 20:33:59 CEST 2015

On Mon, Aug 31, 2015 at 1:58 PM, Tim Peters <tim.peters at gmail.com> wrote:

> I think I'd rather acknowledge that problem cases exist in a direct
> and straightforward way, by adding a new tzinfo (say).classify()
> method.  For example, .classify() could return a
>     (kind, detail)
> 2-tuple.
> - kind==DTKIND_NORMAL.
>   Not an exceptional case.
>   detail is None.
>   The datetime is in a fold, and its `fold` value is sane.
>   detail is the datetime's `fold` value (0 or 1).
>   The datetime does not have `fold==0`, but the datetime is not in a fold.
>   detail is the datetime's `fold` value (whatever it may be).
> - kind==DTKIND_GAP.
>   The datetime is in a gap.
>   detail is a (d1, d2) 2-tuple, where `d1` and `d2` are
>   timedeltas such that (in classic arithmetic):
>       datetime - d1 is the closest earlier non-gap time
>       datetime + d2 is the closest later non-gap time
> Users can call that directly when they like.

I have no objection to this method as long as a default implementation in
terms of a PEP 495 compliant .utcoffset() is provided in the basic
datetime.tzinfo.   Not a bad idea for another PEP. :-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150831/0364d703/attachment.html>

More information about the Datetime-SIG mailing list