Esempio n. 1
0
    def test_timestamp_tz_arg_dateutil(self):
        from pandas._libs.tslib import _dateutil_gettz as gettz
        from pandas._libs.tslib import maybe_get_tz
        for case in ['dateutil/Europe/Brussels', 'dateutil/Asia/Tokyo',
                     'dateutil/US/Pacific']:
            p = Period('1/1/2005', freq='M').to_timestamp(
                tz=maybe_get_tz(case))
            exp = Timestamp('1/1/2005', tz='UTC').tz_convert(case)
            assert p == exp
            assert p.tz == gettz(case.split('/', 1)[1])
            assert p.tz == exp.tz

            p = Period('1/1/2005',
                       freq='M').to_timestamp(freq='3H', tz=maybe_get_tz(case))
            exp = Timestamp('1/1/2005', tz='UTC').tz_convert(case)
            assert p == exp
            assert p.tz == gettz(case.split('/', 1)[1])
            assert p.tz == exp.tz
Esempio n. 2
0
    def test_range_tz_dateutil(self):
        # GH 2906
        tm._skip_if_no_dateutil()
        # Use maybe_get_tz to fix filename in tz under dateutil.
        from pandas._libs.tslib import maybe_get_tz
        tz = lambda x: maybe_get_tz('dateutil/' + x)

        start = datetime(2011, 1, 1, tzinfo=tz('US/Eastern'))
        end = datetime(2011, 1, 3, tzinfo=tz('US/Eastern'))

        dr = date_range(start=start, periods=3)
        self.assertTrue(dr.tz == tz('US/Eastern'))
        self.assertTrue(dr[0] == start)
        self.assertTrue(dr[2] == end)

        dr = date_range(end=end, periods=3)
        self.assertTrue(dr.tz == tz('US/Eastern'))
        self.assertTrue(dr[0] == start)
        self.assertTrue(dr[2] == end)

        dr = date_range(start=start, end=end)
        self.assertTrue(dr.tz == tz('US/Eastern'))
        self.assertTrue(dr[0] == start)
        self.assertTrue(dr[2] == end)
Esempio n. 3
0
    def test_range_tz_dateutil(self):
        # see gh-2906

        # Use maybe_get_tz to fix filename in tz under dateutil.
        from pandas._libs.tslib import maybe_get_tz
        tz = lambda x: maybe_get_tz('dateutil/' + x)

        start = datetime(2011, 1, 1, tzinfo=tz('US/Eastern'))
        end = datetime(2011, 1, 3, tzinfo=tz('US/Eastern'))

        dr = date_range(start=start, periods=3)
        assert dr.tz == tz('US/Eastern')
        assert dr[0] == start
        assert dr[2] == end

        dr = date_range(end=end, periods=3)
        assert dr.tz == tz('US/Eastern')
        assert dr[0] == start
        assert dr[2] == end

        dr = date_range(start=start, end=end)
        assert dr.tz == tz('US/Eastern')
        assert dr[0] == start
        assert dr[2] == end
Esempio n. 4
0
    def test_range_tz_dateutil(self):
        # GH 2906
        tm._skip_if_no_dateutil()
        # Use maybe_get_tz to fix filename in tz under dateutil.
        from pandas._libs.tslib import maybe_get_tz
        tz = lambda x: maybe_get_tz('dateutil/' + x)

        start = datetime(2011, 1, 1, tzinfo=tz('US/Eastern'))
        end = datetime(2011, 1, 3, tzinfo=tz('US/Eastern'))

        dr = date_range(start=start, periods=3)
        self.assertTrue(dr.tz == tz('US/Eastern'))
        self.assertTrue(dr[0] == start)
        self.assertTrue(dr[2] == end)

        dr = date_range(end=end, periods=3)
        self.assertTrue(dr.tz == tz('US/Eastern'))
        self.assertTrue(dr[0] == start)
        self.assertTrue(dr[2] == end)

        dr = date_range(start=start, end=end)
        self.assertTrue(dr.tz == tz('US/Eastern'))
        self.assertTrue(dr[0] == start)
        self.assertTrue(dr[2] == end)
Esempio n. 5
0
    def test_range_tz_dateutil(self):
        # see gh-2906

        # Use maybe_get_tz to fix filename in tz under dateutil.
        from pandas._libs.tslib import maybe_get_tz
        tz = lambda x: maybe_get_tz('dateutil/' + x)

        start = datetime(2011, 1, 1, tzinfo=tz('US/Eastern'))
        end = datetime(2011, 1, 3, tzinfo=tz('US/Eastern'))

        dr = date_range(start=start, periods=3)
        assert dr.tz == tz('US/Eastern')
        assert dr[0] == start
        assert dr[2] == end

        dr = date_range(end=end, periods=3)
        assert dr.tz == tz('US/Eastern')
        assert dr[0] == start
        assert dr[2] == end

        dr = date_range(start=start, end=end)
        assert dr.tz == tz('US/Eastern')
        assert dr[0] == start
        assert dr[2] == end