@@ -58,6 +58,15 @@ def _skip_if_has_locale():
5858 lang , _ = locale .getlocale ()
5959 if lang is not None :
6060 raise nose .SkipTest ("Specific locale is set {0}" .format (lang ))
61+
62+ def _skip_if_windows_python_3 ():
63+ if sys .version_info > (3 ,) and sys .platform == 'win32' :
64+ raise nose .SkipTest ("not used on python 3/win32" )
65+
66+ def _skip_if_not_windows_python_3 ():
67+ if sys .version_info < (3 ,) or sys .platform != 'win32' :
68+ raise nose .SkipTest ("only run on python 3/win32" )
69+
6170
6271class TestTimeSeriesDuplicates (tm .TestCase ):
6372 _multiprocess_can_split_ = True
@@ -406,6 +415,16 @@ def test_timestamp_to_datetime(self):
406415 self .assertEqual (stamp , dtval )
407416 self .assertEqual (stamp .tzinfo , dtval .tzinfo )
408417
418+ def test_timestamp_to_datetime_dateutil (self ):
419+ _skip_if_no_pytz ()
420+ rng = date_range ('20090415' , '20090519' ,
421+ tz = 'dateutil/US/Eastern' )
422+
423+ stamp = rng [0 ]
424+ dtval = stamp .to_pydatetime ()
425+ self .assertEqual (stamp , dtval )
426+ self .assertEqual (stamp .tzinfo , dtval .tzinfo )
427+
409428 def test_timestamp_to_datetime_explicit_pytz (self ):
410429 _skip_if_no_pytz ()
411430 import pytz
@@ -418,6 +437,7 @@ def test_timestamp_to_datetime_explicit_pytz(self):
418437 self .assertEquals (stamp .tzinfo , dtval .tzinfo )
419438
420439 def test_timestamp_to_datetime_explicit_dateutil (self ):
440+ _skip_if_windows_python_3 ()
421441 _skip_if_no_dateutil ()
422442 import dateutil
423443 rng = date_range ('20090415' , '20090519' ,
@@ -467,7 +487,7 @@ def _check_rng(rng):
467487 _check_rng (rng_eastern )
468488 _check_rng (rng_utc )
469489
470- def test_index_convert_to_datetime_array_explicit_dateutil (self ):
490+ def test_index_convert_to_datetime_array_dateutil (self ):
471491 _skip_if_no_dateutil ()
472492 import dateutil
473493
@@ -480,8 +500,8 @@ def _check_rng(rng):
480500 self .assertEquals (x .tzinfo , stamp .tzinfo )
481501
482502 rng = date_range ('20090415' , '20090519' )
483- rng_eastern = date_range ('20090415' , '20090519' , tz = dateutil . tz . gettz ( ' US/Eastern') )
484- rng_utc = date_range ('20090415' , '20090519' , tz = dateutil .tz .gettz ( 'UTC' ))
503+ rng_eastern = date_range ('20090415' , '20090519' , tz = 'dateutil/ US/Eastern' )
504+ rng_utc = date_range ('20090415' , '20090519' , tz = dateutil .tz .tzutc ( ))
485505
486506 _check_rng (rng )
487507 _check_rng (rng_eastern )
@@ -1560,22 +1580,22 @@ def test_to_period_tz_explicit_pytz(self):
15601580 self .assert_ (result == expected )
15611581 self .assert_ (ts .to_period ().equals (xp ))
15621582
1563- def test_to_period_tz_explicit_dateutil (self ):
1583+ def test_to_period_tz_dateutil (self ):
15641584 _skip_if_no_dateutil ()
15651585 import dateutil
15661586 from dateutil .tz import tzlocal
15671587
15681588 xp = date_range ('1/1/2000' , '4/1/2000' ).to_period ()
15691589
1570- ts = date_range ('1/1/2000' , '4/1/2000' , tz = dateutil . tz . gettz ( ' US/Eastern') )
1590+ ts = date_range ('1/1/2000' , '4/1/2000' , tz = 'dateutil/ US/Eastern' )
15711591
15721592 result = ts .to_period ()[0 ]
15731593 expected = ts [0 ].to_period ()
15741594
15751595 self .assert_ (result == expected )
15761596 self .assert_ (ts .to_period ().equals (xp ))
15771597
1578- ts = date_range ('1/1/2000' , '4/1/2000' , tz = dateutil .tz .gettz ( 'UTC' ))
1598+ ts = date_range ('1/1/2000' , '4/1/2000' , tz = dateutil .tz .tzutc ( ))
15791599
15801600 result = ts .to_period ()[0 ]
15811601 expected = ts [0 ].to_period ()
@@ -1793,17 +1813,17 @@ def test_append_concat_tz_explicit_pytz(self):
17931813 appended = rng .append (rng2 )
17941814 self .assert_ (appended .equals (rng3 ))
17951815
1796- def test_append_concat_tz_explicit_dateutil (self ):
1816+ def test_append_concat_tz_dateutil (self ):
17971817 # GH 2938
17981818 _skip_if_no_dateutil ()
17991819 from dateutil .tz import gettz as timezone
18001820
18011821 rng = date_range ('5/8/2012 1:45' , periods = 10 , freq = '5T' ,
1802- tz = timezone ( ' US/Eastern') )
1822+ tz = 'dateutil/ US/Eastern' )
18031823 rng2 = date_range ('5/8/2012 2:35' , periods = 10 , freq = '5T' ,
1804- tz = timezone ( ' US/Eastern') )
1824+ tz = 'dateutil/ US/Eastern' )
18051825 rng3 = date_range ('5/8/2012 1:45' , periods = 20 , freq = '5T' ,
1806- tz = timezone ( ' US/Eastern') )
1826+ tz = 'dateutil/ US/Eastern' )
18071827 ts = Series (np .random .randn (len (rng )), rng )
18081828 df = DataFrame (np .random .randn (len (rng ), 4 ), index = rng )
18091829 ts2 = Series (np .random .randn (len (rng2 )), rng2 )
@@ -2021,11 +2041,11 @@ def test_period_resample_with_local_timezone_dateutil(self):
20212041 _skip_if_no_dateutil ()
20222042 import dateutil
20232043
2024- local_timezone = dateutil . tz . gettz ( ' America/Los_Angeles')
2044+ local_timezone = 'dateutil/ America/Los_Angeles'
20252045
2026- start = datetime (year = 2013 , month = 11 , day = 1 , hour = 0 , minute = 0 , tzinfo = dateutil .tz .gettz ( 'UTC' ))
2046+ start = datetime (year = 2013 , month = 11 , day = 1 , hour = 0 , minute = 0 , tzinfo = dateutil .tz .tzutc ( ))
20272047 # 1 day later
2028- end = datetime (year = 2013 , month = 11 , day = 2 , hour = 0 , minute = 0 , tzinfo = dateutil .tz .gettz ( 'UTC' ))
2048+ end = datetime (year = 2013 , month = 11 , day = 2 , hour = 0 , minute = 0 , tzinfo = dateutil .tz .tzutc ( ))
20292049
20302050 index = pd .date_range (start , end , freq = 'H' )
20312051
@@ -2990,13 +3010,13 @@ def compare(x, y):
29903010
29913011 def test_class_ops_dateutil (self ):
29923012 _skip_if_no_dateutil ()
2993- from dateutil .tz import gettz as timezone
3013+ from dateutil .tz import tzutc
29943014
29953015 def compare (x ,y ):
29963016 self .assertEqual (int (np .round (Timestamp (x ).value / 1e9 )), int (np .round (Timestamp (y ).value / 1e9 )))
29973017
29983018 compare (Timestamp .now (),datetime .now ())
2999- compare (Timestamp .now ('UTC' ), datetime .now (timezone ( 'UTC' )))
3019+ compare (Timestamp .now ('UTC' ), datetime .now (tzutc ( )))
30003020 compare (Timestamp .utcnow (),datetime .utcnow ())
30013021 compare (Timestamp .today (),datetime .today ())
30023022
@@ -3149,8 +3169,8 @@ def test_cant_compare_tz_naive_w_aware_explicit_pytz(self):
31493169
31503170 def test_cant_compare_tz_naive_w_aware_dateutil (self ):
31513171 _skip_if_no_dateutil ()
3152- from dateutil .tz import gettz
3153- utc = gettz ( 'UTC' )
3172+ from dateutil .tz import tzutc
3173+ utc = tzutc ( )
31543174 # #1404
31553175 a = Timestamp ('3/12/2012' )
31563176 b = Timestamp ('3/12/2012' , tz = utc )
0 commit comments