[Datetime-SIG] Trivial vs easy: .utcoffset()
tim.peters at gmail.com
Mon Aug 31 00:19:40 CEST 2015
> Easy idea: after loading a tzfile, create and store (on the tzinfo
> instance) a list of every unique total UTC offset in the zone's
> history, ordered by most recent to least. .utcoffset() then only
> needs to march through that list once, seeing whether the input minus
> the current offset (from the list) converts back to the input via
> .fromutc(). If none do, that's an internal error.
Not quite. "Converts back" has to include reproducing the `fold`
value too. If a user gives a datetime with fold=1 where it doesn't
make sense,.fromutc() can't reproduce it.
Likewise if a user gives a datetime in a gap.
With enough extra annoying code, useful error messages for those could
be produced. I wouldn't want to _guess_ the intent in either of those
It's an internal error if neither of those apply.
More information about the Datetime-SIG