thombashi / DateTimeRange

DateTimeRange is a Python library to handle a time range. e.g. check whether a time is within the time range, get the intersection of time ranges, truncate a time range, iterate through a time range, and so forth.
https://datetimerange.rtfd.io/
MIT License
106 stars 16 forks source link

Daylight Savings Time #8

Closed tweyter closed 8 years ago

tweyter commented 8 years ago

time_range = DateTimeRange("2015-11-01T00:00:00-0400", "2015-11-01T12:00:00-0400") time_range.timedelta datetime.timedelta(0, 43200) # 12 hours Should be 13 hours, because of the time zone change that occurred at 2am. dateutil does not handle time zone aware times as well as pytz does. This will affect your timedelta method as well as eq, ne etc.

thombashi commented 8 years ago

I have fixed the problem.

>>> from datetimerange import DateTimeRange
>>> time_range = DateTimeRange("2015-11-01T00:00:00-0400", "2015-11-01T12:00:00-0400")
>>> time_range.timedelta
datetime.timedelta(0, 46800)  # 13 hours

Thank you for the feedback.

tweyter commented 8 years ago

どういたしまして