I agree and my 2 cents: I can expect something different depending on the timezone and DST if I add
years months weeks days hours minutes seconds
to a given datetime
Even though, in 90% of the cases, there is a more or less obvious conversion formula between all of them. But consider months to days. That is not clear at all.
On 27.07.2015 19:11, Chris Angelico wrote:
On Tue, Jul 28, 2015 at 12:57 AM, Ronald Oussoren firstname.lastname@example.org 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).
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 _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/srkunze%40mail.de