当前位置: 首页>>代码示例>>Python>>正文


Python timedelta.min方法代码示例

本文整理汇总了Python中datetime.timedelta.min方法的典型用法代码示例。如果您正苦于以下问题:Python timedelta.min方法的具体用法?Python timedelta.min怎么用?Python timedelta.min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在datetime.timedelta的用法示例。


在下文中一共展示了timedelta.min方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_extreme_ordinals

# 需要导入模块: from datetime import timedelta [as 别名]
# 或者: from datetime.timedelta 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:IronLanguages,项目名称:ironpython2,代码行数:26,代码来源:test_datetime.py

示例2: test_overflow

# 需要导入模块: from datetime import timedelta [as 别名]
# 或者: from datetime.timedelta 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

示例3: test_resolution_info

# 需要导入模块: from datetime import timedelta [as 别名]
# 或者: from datetime.timedelta 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:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_datetime.py

示例4: test_overflow

# 需要导入模块: from datetime import timedelta [as 别名]
# 或者: from datetime.timedelta 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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:16,代码来源:test_datetime.py

示例5: test_bool

# 需要导入模块: from datetime import timedelta [as 别名]
# 或者: from datetime.timedelta import min [as 别名]
def test_bool(self):
        # All dates are considered true.
        self.assertTrue(self.theclass.min)
        self.assertTrue(self.theclass.max) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_datetime.py

示例6: test_str

# 需要导入模块: from datetime import timedelta [as 别名]
# 或者: from datetime.timedelta 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


注:本文中的datetime.timedelta.min方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。