-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: nonexistent Timestamp pre-summer/winter DST w/dateutil timezone #31155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
651a55f
c9a87bd
ca34eed
65b3bb8
1eb9500
2f3850e
6c87f1b
43f6645
b1defde
e46c774
4f8b490
f8dfb36
3ad3212
2174ca0
0cf53c1
3f79c3d
1c147d3
f03e7c9
c88e354
109a285
8e754f7
894ed16
614176f
56a3e71
89a5c01
9d21a81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
Tests for DatetimeIndex timezone-related methods | ||
""" | ||
from datetime import date, datetime, time, timedelta, tzinfo | ||
from distutils.version import LooseVersion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to parse version properly, so have to import this. |
||
|
||
import dateutil | ||
from dateutil.tz import gettz, tzlocal | ||
|
@@ -10,6 +11,7 @@ | |
import pytz | ||
|
||
from pandas._libs.tslibs import conversion, timezones | ||
from pandas.compat._optional import _get_version | ||
import pandas.util._test_decorators as td | ||
|
||
import pandas as pd | ||
|
@@ -585,7 +587,10 @@ def test_dti_construction_ambiguous_endpoint(self, tz): | |
"dateutil/US/Pacific", | ||
"shift_backward", | ||
"2019-03-10 01:00", | ||
marks=pytest.mark.xfail(reason="GH 24329"), | ||
marks=pytest.mark.xfail( | ||
LooseVersion(_get_version(dateutil)) < LooseVersion("2.7.0"), | ||
reason="GH 31043", | ||
), | ||
), | ||
["US/Pacific", timedelta(hours=1), "2019-03-10 03:00"], | ||
], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import calendar | ||
from datetime import datetime, timedelta | ||
from distutils.version import LooseVersion | ||
import locale | ||
import unicodedata | ||
|
||
|
@@ -1092,3 +1093,23 @@ def test_constructor_ambigous_dst(): | |
expected = ts.value | ||
result = Timestamp(ts).value | ||
assert result == expected | ||
|
||
|
||
@pytest.mark.xfail( | ||
LooseVersion(compat._optional._get_version(dateutil)) < LooseVersion("2.7.0"), | ||
reason="dateutil moved to Timedelta.total_seconds() in 2.7.0", | ||
) | ||
@pytest.mark.parametrize("epoch", [1552211999999999872, 1552211999999999999]) | ||
def test_constructor_before_dst_switch(epoch): | ||
# GH 31043 | ||
# Make sure that calling Timestamp constructor | ||
# on time just before DST switch doesn't lead to | ||
# nonexistent time or value change | ||
# Works only with dateutil >= 2.7.0 as dateutil overrid | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/overrid/overrode |
||
# pandas.Timedelta.total_seconds with | ||
# datetime.timedelta.total_seconds before | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not make sense to me - def total_seconds(td):
useconds = td.days * 86400
useconds += td.seconds
useconds *= 1000000
useconds += td.microseconds
return useconds / 1e6 I think there's actually a deeper issue here, which is that def to_ns(td):
ns = td.days * 86400
ns += td.seconds
ns *= 1000000
ns += td.microseconds
ns *= 1000
ns += td.nanoseconds
return ns
td = timedelta(1552211999999999872, unit="ns")
print(td.value) # 1552211999999999872
print(to_ns(td)) # 1552212000000000872 That seems to be the actual root cause of this issue and should probably be fixed. |
||
ts = Timestamp(epoch, tz="dateutil/US/Pacific") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forgot to mention earlier: you should probably use |
||
result = ts.tz.dst(ts) | ||
expected = timedelta(seconds=0) | ||
assert Timestamp(ts).value == epoch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mroeschke |
||
assert result == expected | ||
AlexKirko marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.