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


Python datetime.MAXYEAR屬性代碼示例

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


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

示例1: test_bad_constructor_arguments

# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import MAXYEAR [as 別名]
def test_bad_constructor_arguments(self):
        # bad years
        self.theclass(MINYEAR, 1, 1)  # no exception
        self.theclass(MAXYEAR, 1, 1)  # no exception
        self.assertRaises(ValueError, self.theclass, MINYEAR-1, 1, 1)
        self.assertRaises(ValueError, self.theclass, MAXYEAR+1, 1, 1)
        # bad months
        self.theclass(2000, 1, 1)    # no exception
        self.theclass(2000, 12, 1)   # no exception
        self.assertRaises(ValueError, self.theclass, 2000, 0, 1)
        self.assertRaises(ValueError, self.theclass, 2000, 13, 1)
        # bad days
        self.theclass(2000, 2, 29)   # no exception
        self.theclass(2004, 2, 29)   # no exception
        self.theclass(2400, 2, 29)   # no exception
        self.assertRaises(ValueError, self.theclass, 2000, 2, 30)
        self.assertRaises(ValueError, self.theclass, 2001, 2, 29)
        self.assertRaises(ValueError, self.theclass, 2100, 2, 29)
        self.assertRaises(ValueError, self.theclass, 1900, 2, 29)
        self.assertRaises(ValueError, self.theclass, 2000, 1, 0)
        self.assertRaises(ValueError, self.theclass, 2000, 1, 32) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:23,代碼來源:test_datetime.py

示例2: test_tz_independent_comparing

# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import MAXYEAR [as 別名]
def test_tz_independent_comparing(self):
        dt1 = self.theclass(2002, 3, 1, 9, 0, 0)
        dt2 = self.theclass(2002, 3, 1, 10, 0, 0)
        dt3 = self.theclass(2002, 3, 1, 9, 0, 0)
        self.assertEqual(dt1, dt3)
        self.assertTrue(dt2 > dt3)

        # Make sure comparison doesn't forget microseconds, and isn't done
        # via comparing a float timestamp (an IEEE double doesn't have enough
        # precision to span microsecond resolution across years 1 thru 9999,
        # so comparing via timestamp necessarily calls some distinct values
        # equal).
        dt1 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999998)
        us = timedelta(microseconds=1)
        dt2 = dt1 + us
        self.assertEqual(dt2 - dt1, us)
        self.assertTrue(dt1 < dt2) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:19,代碼來源:test_datetime.py

示例3: test_constants

# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import MAXYEAR [as 別名]
def test_constants(self):
        import datetime
        self.assertEqual(datetime.MINYEAR, 1)
        self.assertEqual(datetime.MAXYEAR, 9999)

#############################################################################
# tzinfo tests 
開發者ID:gcblue,項目名稱:gcblue,代碼行數:9,代碼來源:test_datetime.py

示例4: test_constants

# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import MAXYEAR [as 別名]
def test_constants(self):
        datetime = datetime_module
        self.assertEqual(datetime.MINYEAR, 1)
        self.assertEqual(datetime.MAXYEAR, 9999) 
開發者ID:ShikyoKira,項目名稱:Project-New-Reign---Nemesis-Main,代碼行數:6,代碼來源:datetimetester.py

示例5: test_tz_independent_comparing

# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import MAXYEAR [as 別名]
def test_tz_independent_comparing(self):
        dt1 = self.theclass(2002, 3, 1, 9, 0, 0)
        dt2 = self.theclass(2002, 3, 1, 10, 0, 0)
        dt3 = self.theclass(2002, 3, 1, 9, 0, 0)
        self.assertEqual(dt1, dt3)
        self.assert_(dt2 > dt3)

        # Make sure comparison doesn't forget microseconds, and isn't done
        # via comparing a float timestamp (an IEEE double doesn't have enough
        # precision to span microsecond resolution across years 1 thru 9999,
        # so comparing via timestamp necessarily calls some distinct values
        # equal).
        dt1 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999998)
        us = timedelta(microseconds=1)
        dt2 = dt1 + us
        self.assertEqual(dt2 - dt1, us)
        self.assert_(dt1 < dt2) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:19,代碼來源:test_datetime.py

示例6: test_name_cleanup

# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import MAXYEAR [as 別名]
def test_name_cleanup(self):
        if '_Fast' not in str(self):
            return
        datetime = datetime_module
        names = set(name for name in dir(datetime)
                    if not name.startswith('__') and not name.endswith('__'))
        allowed = set(['MAXYEAR', 'MINYEAR', 'date', 'datetime',
                       'datetime_CAPI', 'time', 'timedelta', 'timezone',
                       'tzinfo'])
        self.assertEqual(names - allowed, set([])) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:12,代碼來源:datetimetester.py

示例7: test_extreme_hashes

# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import MAXYEAR [as 別名]
def test_extreme_hashes(self):
        # If an attempt is made to hash these via subtracting the offset
        # then hashing a datetime object, OverflowError results.  The
        # Python implementation used to blow up here.
        t = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, ""))
        hash(t)
        t = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999999,
                          tzinfo=FixedOffset(-1439, ""))
        hash(t)

        # OTOH, an OOB offset should blow up.
        t = self.theclass(5, 5, 5, tzinfo=FixedOffset(-1440, ""))
        self.assertRaises(ValueError, hash, t) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:15,代碼來源:datetimetester.py


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