Skip to content

Commit

Permalink
COMPAT with dateutil 2.6.1, fixed ambiguous tz dst behavior (#16880)
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback authored Jul 11, 2017
1 parent d236f31 commit 55af1ab
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
1 change: 0 additions & 1 deletion ci/requirements-3.5.run
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
python-dateutil
pytz
numpy=1.11.3
openpyxl
Expand Down
4 changes: 4 additions & 0 deletions ci/requirements-3.5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ source activate pandas
echo "install 35"

conda install -n pandas -c conda-forge feather-format

# pip install python-dateutil to get latest
conda remove -n pandas python-dateutil --force
pip install python-dateutil
1 change: 0 additions & 1 deletion ci/requirements-3.6_NUMPY_DEV.run
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
python-dateutil
pytz
5 changes: 4 additions & 1 deletion pandas/tests/tseries/test_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4844,14 +4844,17 @@ def test_fallback_plural(self):
hrs_pre = utc_offsets['utc_offset_daylight']
hrs_post = utc_offsets['utc_offset_standard']

if dateutil.__version__ != LooseVersion('2.6.0'):
if dateutil.__version__ < LooseVersion('2.6.0'):
# buggy ambiguous behavior in 2.6.0
# GH 14621
# https://github.com/dateutil/dateutil/issues/321
self._test_all_offsets(
n=3, tstart=self._make_timestamp(self.ts_pre_fallback,
hrs_pre, tz),
expected_utc_offset=hrs_post)
elif dateutil.__version__ > LooseVersion('2.6.0'):
# fixed, but skip the test
continue

def test_springforward_plural(self):
# test moving from standard to daylight savings
Expand Down
21 changes: 17 additions & 4 deletions pandas/tests/tseries/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,16 @@ def f():
tz=tz, ambiguous='infer')
assert times[0] == Timestamp('2013-10-26 23:00', tz=tz, freq="H")

if dateutil.__version__ != LooseVersion('2.6.0'):
# see gh-14621
if str(tz).startswith('dateutil'):
if dateutil.__version__ < LooseVersion('2.6.0'):
# see gh-14621
assert times[-1] == Timestamp('2013-10-27 01:00:00+0000',
tz=tz, freq="H")
elif dateutil.__version__ > LooseVersion('2.6.0'):
# fixed ambiguous behavior
assert times[-1] == Timestamp('2013-10-27 01:00:00+0100',
tz=tz, freq="H")
else:
assert times[-1] == Timestamp('2013-10-27 01:00:00+0000',
tz=tz, freq="H")

Expand Down Expand Up @@ -1233,13 +1241,18 @@ def test_ambiguous_compat(self):
assert result_pytz.value == result_dateutil.value
assert result_pytz.value == 1382835600000000000

# dateutil 2.6 buggy w.r.t. ambiguous=0
if dateutil.__version__ != LooseVersion('2.6.0'):
if dateutil.__version__ < LooseVersion('2.6.0'):
# dateutil 2.6 buggy w.r.t. ambiguous=0
# see gh-14621
# see https://github.com/dateutil/dateutil/issues/321
assert (result_pytz.to_pydatetime().tzname() ==
result_dateutil.to_pydatetime().tzname())
assert str(result_pytz) == str(result_dateutil)
elif dateutil.__version__ > LooseVersion('2.6.0'):
# fixed ambiguous behavior
assert result_pytz.to_pydatetime().tzname() == 'GMT'
assert result_dateutil.to_pydatetime().tzname() == 'BST'
assert str(result_pytz) != str(result_dateutil)

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

0 comments on commit 55af1ab

Please sign in to comment.