當前位置: 首頁>>代碼示例>>Python>>正文


Python tzwin.tzwinlocal方法代碼示例

本文整理匯總了Python中dateutil.tzwin.tzwinlocal方法的典型用法代碼示例。如果您正苦於以下問題:Python tzwin.tzwinlocal方法的具體用法?Python tzwin.tzwinlocal怎麽用?Python tzwin.tzwinlocal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dateutil.tzwin的用法示例。


在下文中一共展示了tzwin.tzwinlocal方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testTzwinLocalName

# 需要導入模塊: from dateutil import tzwin [as 別名]
# 或者: from dateutil.tzwin import tzwinlocal [as 別名]
def testTzwinLocalName(self):
        # https://github.com/dateutil/dateutil/issues/143
        ESTs = 'Eastern Standard Time'
        EDTs = 'Eastern Daylight Time'
        transition_dates = [(datetime(2015, 3, 8, 0, 59), ESTs),
                            (datetime(2015, 3, 8, 3, 1), EDTs),
                            (datetime(2015, 11, 1, 0, 59), EDTs),
                            (datetime(2015, 11, 1, 3, 1), ESTs),
                            (datetime(2016, 3, 13, 0, 59), ESTs),
                            (datetime(2016, 3, 13, 3, 1), EDTs),
                            (datetime(2016, 11, 6, 0, 59), EDTs),
                            (datetime(2016, 11, 6, 3, 1), ESTs)]

        with TZWinContext('Eastern Standard Time'):
            tw = tz.tzwinlocal()

            for t_date, expected in transition_dates:
                self.assertEqual(t_date.replace(tzinfo=tw).tzname(), expected) 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:20,代碼來源:test_tz.py

示例2: testTzwinLocalEquality

# 需要導入模塊: from dateutil import tzwin [as 別名]
# 或者: from dateutil.tzwin import tzwinlocal [as 別名]
def testTzwinLocalEquality(self):
        tw_est = tz.tzwin('Eastern Standard Time')
        tw_pst = tz.tzwin('Pacific Standard Time')

        with TZWinContext('Eastern Standard Time'):
            twl1 = tz.tzwinlocal()
            twl2 = tz.tzwinlocal()

            self.assertEqual(twl1, twl2)
            self.assertEqual(twl1, tw_est)
            self.assertNotEqual(twl1, tw_pst)

        with TZWinContext('Pacific Standard Time'):
            twl1 = tz.tzwinlocal()
            twl2 = tz.tzwinlocal()
            tw = tz.tzwin('Pacific Standard Time')

            self.assertEqual(twl1, twl2)
            self.assertEqual(twl1, tw)
            self.assertEqual(twl1, tw_pst)
            self.assertNotEqual(twl1, tw_est) 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:23,代碼來源:test_tz.py

示例3: testTzAll

# 需要導入模塊: from dateutil import tzwin [as 別名]
# 或者: from dateutil.tzwin import tzwinlocal [as 別名]
def testTzAll(self):
        from dateutil.tz import tzutc
        from dateutil.tz import tzoffset
        from dateutil.tz import tzlocal
        from dateutil.tz import tzfile
        from dateutil.tz import tzrange
        from dateutil.tz import tzstr
        from dateutil.tz import tzical
        from dateutil.tz import gettz
        from dateutil.tz import tzwin
        from dateutil.tz import tzwinlocal
        from dateutil.tz import UTC
        from dateutil.tz import datetime_ambiguous
        from dateutil.tz import datetime_exists
        from dateutil.tz import resolve_imaginary

        tz_all = ["tzutc", "tzoffset", "tzlocal", "tzfile", "tzrange",
                  "tzstr", "tzical", "gettz", "datetime_ambiguous",
                  "datetime_exists", "resolve_imaginary", "UTC"]

        tz_all += ["tzwin", "tzwinlocal"] if sys.platform.startswith("win") else []
        lvars = locals()

        for var in tz_all:
            self.assertIsNot(lvars[var], None) 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:27,代碼來源:test_imports.py

示例4: setUp

# 需要導入模塊: from dateutil import tzwin [as 別名]
# 或者: from dateutil.tzwin import tzwinlocal [as 別名]
def setUp(self):
        self.tzclass = tzwin.tzwinlocal
        self.context = TZWinContext 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:5,代碼來源:test_tz.py

示例5: testLocal

# 需要導入模塊: from dateutil import tzwin [as 別名]
# 或者: from dateutil.tzwin import tzwinlocal [as 別名]
def testLocal(self):
        # Not sure how to pin a local time zone, so for now we're just going
        # to run this and make sure it doesn't raise an error
        # See Github Issue #135: https://github.com/dateutil/dateutil/issues/135
        datetime.now(tzwin.tzwinlocal()) 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:7,代碼來源:test_tz.py

示例6: testTzwinLocalUTCOffset

# 需要導入模塊: from dateutil import tzwin [as 別名]
# 或者: from dateutil.tzwin import tzwinlocal [as 別名]
def testTzwinLocalUTCOffset(self):
        with TZWinContext('Eastern Standard Time'):
            tzwl = tzwin.tzwinlocal()
            self.assertEqual(datetime(2014, 3, 11, tzinfo=tzwl).utcoffset(),
                             timedelta(hours=-4)) 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:7,代碼來源:test_tz.py

示例7: testTzWinLocalRepr

# 需要導入模塊: from dateutil import tzwin [as 別名]
# 或者: from dateutil.tzwin import tzwinlocal [as 別名]
def testTzWinLocalRepr(self):
        tw = tz.tzwinlocal()
        self.assertEqual(repr(tw), 'tzwinlocal()') 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:5,代碼來源:test_tz.py

示例8: testTzwinLocalTimeOnlyDST

# 需要導入模塊: from dateutil import tzwin [as 別名]
# 或者: from dateutil.tzwin import tzwinlocal [as 別名]
def testTzwinLocalTimeOnlyDST(self):
        # For zones with DST, .dst() should return None
        with TZWinContext('Eastern Standard Time'):
            twl = tz.tzwinlocal()
            self.assertIs(dt_time(14, 10, tzinfo=twl).dst(), None)

        # This zone has no DST, so .dst() can return 0
        with TZWinContext('South Africa Standard Time'):
            twl = tz.tzwinlocal()
            self.assertEqual(dt_time(14, 10, tzinfo=twl).dst(), timedelta(0)) 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:12,代碼來源:test_tz.py

示例9: testTzwinLocalTimeOnlyUTCOffset

# 需要導入模塊: from dateutil import tzwin [as 別名]
# 或者: from dateutil.tzwin import tzwinlocal [as 別名]
def testTzwinLocalTimeOnlyUTCOffset(self):
        # For zones with DST, .utcoffset() should return None
        with TZWinContext('Eastern Standard Time'):
            twl = tz.tzwinlocal()
            self.assertIs(dt_time(14, 10, tzinfo=twl).utcoffset(), None)

        # This zone has no DST, so .utcoffset() returns standard offset
        with TZWinContext('South Africa Standard Time'):
            twl = tz.tzwinlocal()
            self.assertEqual(dt_time(14, 10, tzinfo=twl).utcoffset(),
                             timedelta(hours=2)) 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:13,代碼來源:test_tz.py

示例10: testTzwinLocalTimeOnlyTZName

# 需要導入模塊: from dateutil import tzwin [as 別名]
# 或者: from dateutil.tzwin import tzwinlocal [as 別名]
def testTzwinLocalTimeOnlyTZName(self):
        # For zones with DST, the name defaults to standard time
        with TZWinContext('Eastern Standard Time'):
            twl = tz.tzwinlocal()
            self.assertEqual(dt_time(14, 10, tzinfo=twl).tzname(),
                             'Eastern Standard Time')

        # For zones with no DST, this should work normally.
        with TZWinContext('South Africa Standard Time'):
            twl = tz.tzwinlocal()
            self.assertEqual(dt_time(14, 10, tzinfo=twl).tzname(),
                             'South Africa Standard Time') 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:14,代碼來源:test_tz.py


注:本文中的dateutil.tzwin.tzwinlocal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。