[issue31167] timedelta produced by datetime.__sub__ does not take Daylight Savings Time into account

2017-08-09 Thread R. David Murray

R. David Murray added the comment:

It is by design.  Read the footnote associated with the subtraction opertion on 
datetimes: after subtraction date2 + timedelta = date1, which implies that the 
subtraction ignores daylight savings transitions, since the addition does 
("Note that no time zone adjustments are done even if the input is an aware 
object").

Perhaps the reason why it is designed this way is menioned in the PEP; I 
haven't looked.

--
nosy: +r.david.murray
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31167] timedelta produced by datetime.__sub__ does not take Daylight Savings Time into account

2017-08-09 Thread Joshua Li

New submission from Joshua Li:

See my SO answer and the corresponding question for detail: 
https://stackoverflow.com/a/45602760/5348393

Essentially, given two datetime.datetime instances t1 and t2, the following two 
syntactically different lines of code should be logically equivalent, but in 
fact differ by plus or minus one hour on Daylight Savings Time dates because 
`datetime.datetime.__sub__` does not appear to take DST into account.

`t1.timestamp()-t2.timestamp()`
`(t1-t2).total_seconds()`

I am not sure if this is by intentional design, or a behavioral bug.

--
components: Library (Lib)
messages: 300035
nosy: JoshuaRLi
priority: normal
severity: normal
status: open
title: timedelta produced by datetime.__sub__ does not take Daylight Savings 
Time into account
type: behavior
versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com