On Mon, Aug 31, 2015 at 1:58 PM, Tim Peters <[email protected]> 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. > > - kind==DTKIND_FOLD_NORMAL. > The datetime is in a fold, and its `fold` value is sane. > detail is the datetime's `fold` value (0 or 1). > > - kind==DTKIND_FOLD_INVALID. > 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. :-)
_______________________________________________ Datetime-SIG mailing list [email protected] https://mail.python.org/mailman/listinfo/datetime-sig The PSF Code of Conduct applies to this mailing list: https://www.python.org/psf/codeofconduct/
