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


Python timezone.min方法代碼示例

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


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

示例1: test_overflow

# 需要導入模塊: from datetime import timezone [as 別名]
# 或者: from datetime.timezone import min [as 別名]
def test_overflow(self):
        tiny = timedelta.resolution

        td = timedelta.min + tiny
        td -= tiny  # no problem
        self.assertRaises(OverflowError, td.__sub__, tiny)
        self.assertRaises(OverflowError, td.__add__, -tiny)

        td = timedelta.max - tiny
        td += tiny  # no problem
        self.assertRaises(OverflowError, td.__add__, tiny)
        self.assertRaises(OverflowError, td.__sub__, -tiny)

        self.assertRaises(OverflowError, lambda: -timedelta.max)

        day = timedelta(1)
        self.assertRaises(OverflowError, day.__mul__, 10**9)
        self.assertRaises(OverflowError, day.__mul__, 1e9)
        self.assertRaises(OverflowError, day.__truediv__, 1e-20)
        self.assertRaises(OverflowError, day.__truediv__, 1e-10)
        self.assertRaises(OverflowError, day.__truediv__, 9e-10) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:23,代碼來源:datetimetester.py

示例2: test_extreme_ordinals

# 需要導入模塊: from datetime import timezone [as 別名]
# 或者: from datetime.timezone import min [as 別名]
def test_extreme_ordinals(self):
        a = self.theclass.min
        a = self.theclass(a.year, a.month, a.day)  # get rid of time parts
        aord = a.toordinal()
        b = a.fromordinal(aord)
        self.assertEqual(a, b)

        self.assertRaises(ValueError, lambda: a.fromordinal(aord - 1))

        b = a + timedelta(days=1)
        self.assertEqual(b.toordinal(), aord + 1)
        self.assertEqual(b, self.theclass.fromordinal(aord + 1))

        a = self.theclass.max
        a = self.theclass(a.year, a.month, a.day)  # get rid of time parts
        aord = a.toordinal()
        b = a.fromordinal(aord)
        self.assertEqual(a, b)

        self.assertRaises(ValueError, lambda: a.fromordinal(aord + 1))

        b = a - timedelta(days=1)
        self.assertEqual(b.toordinal(), aord - 1)
        self.assertEqual(b, self.theclass.fromordinal(aord - 1)) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:26,代碼來源:datetimetester.py

示例3: test_str

# 需要導入模塊: from datetime import timezone [as 別名]
# 或者: from datetime.timezone import min [as 別名]
def test_str(self):
        for tz in [self.ACDT, self.EST, timezone.utc,
                   timezone.min, timezone.max]:
            self.assertEqual(str(tz), tz.tzname(None)) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:6,代碼來源:datetimetester.py

示例4: test_repr

# 需要導入模塊: from datetime import timezone [as 別名]
# 或者: from datetime.timezone import min [as 別名]
def test_repr(self):
        datetime = datetime_module
        for tz in [self.ACDT, self.EST, timezone.utc,
                   timezone.min, timezone.max]:
            # test round-trip
            tzrep = repr(tz)
            self.assertEqual(tz, eval(tzrep)) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:9,代碼來源:datetimetester.py

示例5: test_class_members

# 需要導入模塊: from datetime import timezone [as 別名]
# 或者: from datetime.timezone import min [as 別名]
def test_class_members(self):
        limit = timedelta(hours=23, minutes=59)
        self.assertEqual(timezone.utc.utcoffset(None), ZERO)
        self.assertEqual(timezone.min.utcoffset(None), -limit)
        self.assertEqual(timezone.max.utcoffset(None), limit) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:7,代碼來源:datetimetester.py

示例6: test_aware_datetime

# 需要導入模塊: from datetime import timezone [as 別名]
# 或者: from datetime.timezone import min [as 別名]
def test_aware_datetime(self):
        # test that timezone instances can be used by datetime
        t = datetime(1, 1, 1)
        for tz in [timezone.min, timezone.max, timezone.utc]:
            self.assertEqual(tz.tzname(t),
                             t.replace(tzinfo=tz).tzname())
            self.assertEqual(tz.utcoffset(t),
                             t.replace(tzinfo=tz).utcoffset())
            self.assertEqual(tz.dst(t),
                             t.replace(tzinfo=tz).dst()) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:12,代碼來源:datetimetester.py

示例7: test_pickle

# 需要導入模塊: from datetime import timezone [as 別名]
# 或者: from datetime.timezone import min [as 別名]
def test_pickle(self):
        for tz in self.ACDT, self.EST, timezone.min, timezone.max:
            for pickler, unpickler, proto in pickle_choices:
                tz_copy = unpickler.loads(pickler.dumps(tz, proto))
                self.assertEqual(tz_copy, tz)
        tz = timezone.utc
        for pickler, unpickler, proto in pickle_choices:
            tz_copy = unpickler.loads(pickler.dumps(tz, proto))
            self.assertIs(tz_copy, tz) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:11,代碼來源:datetimetester.py

示例8: test_deepcopy

# 需要導入模塊: from datetime import timezone [as 別名]
# 或者: from datetime.timezone import min [as 別名]
def test_deepcopy(self):
        for tz in self.ACDT, self.EST, timezone.min, timezone.max:
            tz_copy = copy.deepcopy(tz)
            self.assertEqual(tz_copy, tz)
        tz = timezone.utc
        tz_copy = copy.deepcopy(tz)
        self.assertIs(tz_copy, tz)


#############################################################################
# Base class for testing a particular aspect of timedelta, time, date and
# datetime comparisons. 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:14,代碼來源:datetimetester.py

示例9: test_resolution_info

# 需要導入模塊: from datetime import timezone [as 別名]
# 或者: from datetime.timezone import min [as 別名]
def test_resolution_info(self):
        self.assertIsInstance(timedelta.min, timedelta)
        self.assertIsInstance(timedelta.max, timedelta)
        self.assertIsInstance(timedelta.resolution, timedelta)
        self.assertTrue(timedelta.max > timedelta.min)
        self.assertEqual(timedelta.min, timedelta(-999999999))
        self.assertEqual(timedelta.max, timedelta(999999999, 24*3600-1, 1e6-1))
        self.assertEqual(timedelta.resolution, timedelta(0, 0, 1)) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:10,代碼來源:datetimetester.py

示例10: test_extreme_timedelta

# 需要導入模塊: from datetime import timezone [as 別名]
# 或者: from datetime.timezone import min [as 別名]
def test_extreme_timedelta(self):
        big = self.theclass.max - self.theclass.min
        # 3652058 days, 23 hours, 59 minutes, 59 seconds, 999999 microseconds
        n = (big.days*24*3600 + big.seconds)*1000000 + big.microseconds
        # n == 315537897599999999 ~= 2**58.13
        justasbig = timedelta(0, 0, n)
        self.assertEqual(big, justasbig)
        self.assertEqual(self.theclass.min + big, self.theclass.max)
        self.assertEqual(self.theclass.max - big, self.theclass.min) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:11,代碼來源:datetimetester.py

示例11: test_bool

# 需要導入模塊: from datetime import timezone [as 別名]
# 或者: from datetime.timezone import min [as 別名]
def test_bool(self):
        # All dates are considered true.
        self.assertTrue(self.theclass.min)
        self.assertTrue(self.theclass.max) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:6,代碼來源:datetimetester.py


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