[Python-Dev] Status on PEP-431 Timezones

Chris Angelico rosuav at gmail.com
Mon Jul 27 19:11:25 CEST 2015


On Tue, Jul 28, 2015 at 12:57 AM, Ronald Oussoren
<ronaldoussoren at mac.com> wrote:
> IMHO “+ 1 days” and “+ 24 hours” are two different things.  Date
> arithmetic is full of messy things like that.  “+ 1 month” is another
> example of that (which the datetime module punts completely
> and can be a source of endless bikeshidding).

https://www.youtube.com/watch?v=ppfpa5XgZHI

MATLAB defines "+ 1 month" as, if I'm not mistaken, "add the time it
would take to go from the beginning of time to the beginning of
January of the year 0 (which is totally a thing, by the way)". I'm
fairly sure that this is the most WAT-worthy definition possible, as
it means that adding one month does nothing, and adding two months
adds the length of January (31 days)... and adding three months adds
January + February, *in a leap year*.

But I agree that adding days and adding hours are different things. If
I add one day, I expect that the time portion should not change, in
the given timezone. (With the exception that DST switches might mean
that that time doesn't exist.) If I add 86400 seconds, I expect that
it should add 86400 ISO seconds to the time period, which might not be
the same thing. If you convert a datetime to a different timezone, add
86400 seconds, and convert back to the original timezone, I would
expect the result to be the same as adding 86400 seconds to the
original, unless there's something seriously bizarre going on with the
size of the second. But if you convert, add 1 day, and convert back,
you will get a different result if the two differ on DST. Does that
sound plausible?

ChrisA


More information about the Python-Dev mailing list