Arrow: daylight savings time and 'ceil()'

Created on 22 Nov 2016  路  4Comments  路  Source: arrow-py/arrow

When the ceiling function is called across a daylight savings time change, the offset is not adjusted:

This is wrong:

>>> arrow.get('2016-11-06').to('America/New_York').ceil('day')
<Arrow [2016-11-05T23:59:59.999999-04:00]>

This is right:

>>> arrow.get('2016-11-06 12:00').to('America/New_York').ceil('day')
<Arrow [2016-11-06T23:59:59.999999-05:00]>

floor() works though:

>>> arrow.get('2016-11-06 12:00').to('America/New_York').floor('day')
<Arrow [2016-11-06T00:00:00-04:00]>
bug

Most helpful comment

I am beginning to look into this issue

All 4 comments

I am beginning to look into this issue

@ajdidonato7 sounds good. The fold attribute provided by dateutil may be useful here to detect a DST transition (ref: https://github.com/crsmithdev/arrow/issues/488).

I will have a pull request for this change in the next few days

I think what was believed to be a bug was actually expected behavior.

The user made the assumption that '2016-11-06 00:00' should not ceil() to

arrow.get('2016-11-06 03:59').to('America/New_York').ceil('day')
<Arrow [2016-11-05T23:59:59.999999-04:00]>

arrow.get('2016-11-06 04:00').to('America/New_York').ceil('day')
<Arrow [2016-11-06T23:59:59.999999-05:00]>

Thoughts on this? @jadchaar @systemcatch I can produce test cases that confirm this if it is correct.

Was this page helpful?
0 / 5 - 0 ratings