On 2015-07-27 15:46, Lennart Regebro wrote:
On Mon, Jul 27, 2015 at 4:13 PM, Steven D'Aprano <st...@pearwood.info> wrote:
To me, Paul's example is a datetime operation: you start with a datetime
(7am today), perform arithmetic on it by adding a period of time (one
day), and get a datetime as the result (7am tomorrow).

Well, OK, let's propose these wordings: It looks like a date
operation, ie, add one to the date, but in reality it's a time
operation, ie add 86400 seconds to the time. These things sound
similar but are very different.

I called it a "calendar" operation, because these operation include
such things as "add one year", where you expect to get the 27th of
July 2016, but you will get the 26th if you use a timedelta, because
2016 is a leap year. So we need to separate date (or calendar)
operations from time operations. The same thing goes with months, add
30 days, and you'll sometimes get the same result as if you add one
month and sometimes not.

Also, if you "add one year" to 29 February 2016, what date do you get?

timedelta adds time, not days, month or years. Except when you cross a
DST border where it suddenly, surprisingly and intentionally may add
more or less time than you told it to.


_______________________________________________
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/archive%40mail-archive.com

Reply via email to