Skip to content

Commit 55af1ab

Browse files
authored
COMPAT with dateutil 2.6.1, fixed ambiguous tz dst behavior (pandas-dev#16880)
1 parent d236f31 commit 55af1ab

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

ci/requirements-3.5.run

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
python-dateutil
21
pytz
32
numpy=1.11.3
43
openpyxl

ci/requirements-3.5.sh

+4
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ source activate pandas
55
echo "install 35"
66

77
conda install -n pandas -c conda-forge feather-format
8+
9+
# pip install python-dateutil to get latest
10+
conda remove -n pandas python-dateutil --force
11+
pip install python-dateutil

ci/requirements-3.6_NUMPY_DEV.run

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
python-dateutil
21
pytz

pandas/tests/tseries/test_offsets.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -4844,14 +4844,17 @@ def test_fallback_plural(self):
48444844
hrs_pre = utc_offsets['utc_offset_daylight']
48454845
hrs_post = utc_offsets['utc_offset_standard']
48464846

4847-
if dateutil.__version__ != LooseVersion('2.6.0'):
4847+
if dateutil.__version__ < LooseVersion('2.6.0'):
48484848
# buggy ambiguous behavior in 2.6.0
48494849
# GH 14621
48504850
# https://github.com/dateutil/dateutil/issues/321
48514851
self._test_all_offsets(
48524852
n=3, tstart=self._make_timestamp(self.ts_pre_fallback,
48534853
hrs_pre, tz),
48544854
expected_utc_offset=hrs_post)
4855+
elif dateutil.__version__ > LooseVersion('2.6.0'):
4856+
# fixed, but skip the test
4857+
continue
48554858

48564859
def test_springforward_plural(self):
48574860
# test moving from standard to daylight savings

pandas/tests/tseries/test_timezones.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,16 @@ def f():
552552
tz=tz, ambiguous='infer')
553553
assert times[0] == Timestamp('2013-10-26 23:00', tz=tz, freq="H")
554554

555-
if dateutil.__version__ != LooseVersion('2.6.0'):
556-
# see gh-14621
555+
if str(tz).startswith('dateutil'):
556+
if dateutil.__version__ < LooseVersion('2.6.0'):
557+
# see gh-14621
558+
assert times[-1] == Timestamp('2013-10-27 01:00:00+0000',
559+
tz=tz, freq="H")
560+
elif dateutil.__version__ > LooseVersion('2.6.0'):
561+
# fixed ambiguous behavior
562+
assert times[-1] == Timestamp('2013-10-27 01:00:00+0100',
563+
tz=tz, freq="H")
564+
else:
557565
assert times[-1] == Timestamp('2013-10-27 01:00:00+0000',
558566
tz=tz, freq="H")
559567

@@ -1233,13 +1241,18 @@ def test_ambiguous_compat(self):
12331241
assert result_pytz.value == result_dateutil.value
12341242
assert result_pytz.value == 1382835600000000000
12351243

1236-
# dateutil 2.6 buggy w.r.t. ambiguous=0
1237-
if dateutil.__version__ != LooseVersion('2.6.0'):
1244+
if dateutil.__version__ < LooseVersion('2.6.0'):
1245+
# dateutil 2.6 buggy w.r.t. ambiguous=0
12381246
# see gh-14621
12391247
# see https://github.com/dateutil/dateutil/issues/321
12401248
assert (result_pytz.to_pydatetime().tzname() ==
12411249
result_dateutil.to_pydatetime().tzname())
12421250
assert str(result_pytz) == str(result_dateutil)
1251+
elif dateutil.__version__ > LooseVersion('2.6.0'):
1252+
# fixed ambiguous behavior
1253+
assert result_pytz.to_pydatetime().tzname() == 'GMT'
1254+
assert result_dateutil.to_pydatetime().tzname() == 'BST'
1255+
assert str(result_pytz) != str(result_dateutil)
12431256

12441257
# 1 hour difference
12451258
result_pytz = (Timestamp('2013-10-27 01:00:00')

0 commit comments

Comments
 (0)