@@ -58,6 +58,15 @@ def _skip_if_has_locale():
58
58
lang , _ = locale .getlocale ()
59
59
if lang is not None :
60
60
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
+
61
70
62
71
class TestTimeSeriesDuplicates (tm .TestCase ):
63
72
_multiprocess_can_split_ = True
@@ -406,6 +415,16 @@ def test_timestamp_to_datetime(self):
406
415
self .assertEqual (stamp , dtval )
407
416
self .assertEqual (stamp .tzinfo , dtval .tzinfo )
408
417
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
+
409
428
def test_timestamp_to_datetime_explicit_pytz (self ):
410
429
_skip_if_no_pytz ()
411
430
import pytz
@@ -418,6 +437,7 @@ def test_timestamp_to_datetime_explicit_pytz(self):
418
437
self .assertEquals (stamp .tzinfo , dtval .tzinfo )
419
438
420
439
def test_timestamp_to_datetime_explicit_dateutil (self ):
440
+ _skip_if_windows_python_3 ()
421
441
_skip_if_no_dateutil ()
422
442
import dateutil
423
443
rng = date_range ('20090415' , '20090519' ,
@@ -467,7 +487,7 @@ def _check_rng(rng):
467
487
_check_rng (rng_eastern )
468
488
_check_rng (rng_utc )
469
489
470
- def test_index_convert_to_datetime_array_explicit_dateutil (self ):
490
+ def test_index_convert_to_datetime_array_dateutil (self ):
471
491
_skip_if_no_dateutil ()
472
492
import dateutil
473
493
@@ -480,8 +500,8 @@ def _check_rng(rng):
480
500
self .assertEquals (x .tzinfo , stamp .tzinfo )
481
501
482
502
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 ( ))
485
505
486
506
_check_rng (rng )
487
507
_check_rng (rng_eastern )
@@ -1560,22 +1580,22 @@ def test_to_period_tz_explicit_pytz(self):
1560
1580
self .assert_ (result == expected )
1561
1581
self .assert_ (ts .to_period ().equals (xp ))
1562
1582
1563
- def test_to_period_tz_explicit_dateutil (self ):
1583
+ def test_to_period_tz_dateutil (self ):
1564
1584
_skip_if_no_dateutil ()
1565
1585
import dateutil
1566
1586
from dateutil .tz import tzlocal
1567
1587
1568
1588
xp = date_range ('1/1/2000' , '4/1/2000' ).to_period ()
1569
1589
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' )
1571
1591
1572
1592
result = ts .to_period ()[0 ]
1573
1593
expected = ts [0 ].to_period ()
1574
1594
1575
1595
self .assert_ (result == expected )
1576
1596
self .assert_ (ts .to_period ().equals (xp ))
1577
1597
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 ( ))
1579
1599
1580
1600
result = ts .to_period ()[0 ]
1581
1601
expected = ts [0 ].to_period ()
@@ -1793,17 +1813,17 @@ def test_append_concat_tz_explicit_pytz(self):
1793
1813
appended = rng .append (rng2 )
1794
1814
self .assert_ (appended .equals (rng3 ))
1795
1815
1796
- def test_append_concat_tz_explicit_dateutil (self ):
1816
+ def test_append_concat_tz_dateutil (self ):
1797
1817
# GH 2938
1798
1818
_skip_if_no_dateutil ()
1799
1819
from dateutil .tz import gettz as timezone
1800
1820
1801
1821
rng = date_range ('5/8/2012 1:45' , periods = 10 , freq = '5T' ,
1802
- tz = timezone ( ' US/Eastern') )
1822
+ tz = 'dateutil/ US/Eastern' )
1803
1823
rng2 = date_range ('5/8/2012 2:35' , periods = 10 , freq = '5T' ,
1804
- tz = timezone ( ' US/Eastern') )
1824
+ tz = 'dateutil/ US/Eastern' )
1805
1825
rng3 = date_range ('5/8/2012 1:45' , periods = 20 , freq = '5T' ,
1806
- tz = timezone ( ' US/Eastern') )
1826
+ tz = 'dateutil/ US/Eastern' )
1807
1827
ts = Series (np .random .randn (len (rng )), rng )
1808
1828
df = DataFrame (np .random .randn (len (rng ), 4 ), index = rng )
1809
1829
ts2 = Series (np .random .randn (len (rng2 )), rng2 )
@@ -2021,11 +2041,11 @@ def test_period_resample_with_local_timezone_dateutil(self):
2021
2041
_skip_if_no_dateutil ()
2022
2042
import dateutil
2023
2043
2024
- local_timezone = dateutil . tz . gettz ( ' America/Los_Angeles')
2044
+ local_timezone = 'dateutil/ America/Los_Angeles'
2025
2045
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 ( ))
2027
2047
# 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 ( ))
2029
2049
2030
2050
index = pd .date_range (start , end , freq = 'H' )
2031
2051
@@ -2990,13 +3010,13 @@ def compare(x, y):
2990
3010
2991
3011
def test_class_ops_dateutil (self ):
2992
3012
_skip_if_no_dateutil ()
2993
- from dateutil .tz import gettz as timezone
3013
+ from dateutil .tz import tzutc
2994
3014
2995
3015
def compare (x ,y ):
2996
3016
self .assertEqual (int (np .round (Timestamp (x ).value / 1e9 )), int (np .round (Timestamp (y ).value / 1e9 )))
2997
3017
2998
3018
compare (Timestamp .now (),datetime .now ())
2999
- compare (Timestamp .now ('UTC' ), datetime .now (timezone ( 'UTC' )))
3019
+ compare (Timestamp .now ('UTC' ), datetime .now (tzutc ( )))
3000
3020
compare (Timestamp .utcnow (),datetime .utcnow ())
3001
3021
compare (Timestamp .today (),datetime .today ())
3002
3022
@@ -3149,8 +3169,8 @@ def test_cant_compare_tz_naive_w_aware_explicit_pytz(self):
3149
3169
3150
3170
def test_cant_compare_tz_naive_w_aware_dateutil (self ):
3151
3171
_skip_if_no_dateutil ()
3152
- from dateutil .tz import gettz
3153
- utc = gettz ( 'UTC' )
3172
+ from dateutil .tz import tzutc
3173
+ utc = tzutc ( )
3154
3174
# #1404
3155
3175
a = Timestamp ('3/12/2012' )
3156
3176
b = Timestamp ('3/12/2012' , tz = utc )
0 commit comments