Skip to content

Wrong hour of DST end for Europe TZ #11481

Closed
@izderadicka

Description

@izderadicka

xref #11708

In Europe DST ends by 2 am (this year on Sunday 2015-10-25), when clock is moved one hour back. However in Timestamp this transition is one hour earlier ( 1 am - which is hour, when transition happens in US I think). pytz works as expected.

See code ( tested in pandas 0.17.0 and 0.16.2):

In [1]: import pandas as pd
In [2]: import pytz
In [3]: from pandas import Timestamp

In [7]: pd.__version__
Out[7]: u'0.17.0'

In [8]: cz_tz=pytz.timezone('Europe/Prague')

In [9]: Timestamp('2015-10-25 00:00', tz=cz_tz)
Out[9]: Timestamp('2015-10-25 00:00:00+0200', tz='Europe/Prague')

In [10]: Timestamp('2015-10-25 01:00', tz=cz_tz)
Out[10]: Timestamp('2015-10-25 02:00:00+0200', tz='Europe/Prague')

In [11]: Timestamp('2015-10-25 02:00', tz=cz_tz)
Out[11]: Timestamp('2015-10-25 02:00:00+0100', tz='Europe/Prague')

In [13]: from pandas.tseries.offsets import Hour

In [14]: Timestamp('2015-10-25 01:00', tz=cz_tz) + Hour(1)
Out[14]: Timestamp('2015-10-25 02:00:00+0100', tz='Europe/Prague')

In [16]: from datetime import datetime

In [17]: cz_tz.dst(datetime(2015,10,25, 1, 0))
Out[17]: datetime.timedelta(0, 3600)

In [18]: cz_tz.dst(datetime(2015,10,25, 2, 0))
---------------------------------------------------------------------------
AmbiguousTimeError                        Traceback (most recent call last)
<ipython-input-18-4b6d0ae06c09> in <module>()
----> 1 cz_tz.dst(datetime(2015,10,25, 2, 0))

/home/ivan/tmp/pandas-test/local/lib/python2.7/site-packages/pytz/tzinfo.pyc in dst(self, dt, is_dst)
    445             return None
    446         elif dt.tzinfo is not self:
--> 447             dt = self.localize(dt, is_dst)
    448             return dt.tzinfo._dst
    449         else:

/home/ivan/tmp/pandas-test/local/lib/python2.7/site-packages/pytz/tzinfo.pyc in localize(self, dt, is_dst)
    347         # ambiguous case
    348         if is_dst is None:
--> 349             raise AmbiguousTimeError(dt)
    350 
    351         # Filter out the possiblilities that don't match the requested

AmbiguousTimeError: 2015-10-25 02:00:00

In [19]: cz_tz.dst(datetime(2015,10,25, 2, 0), is_dst=True)
Out[19]: datetime.timedelta(0, 3600)

In [20]: cz_tz.dst(datetime(2015,10,25, 2, 0), is_dst=False)
Out[20]: datetime.timedelta(0)

In [21]: cz_tz.dst(datetime(2015,10,25, 3, 0))
Out[21]: datetime.timedelta(0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions