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


Python time.mktime方法代码示例

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


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

示例1: test_fromtimestamp

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import mktime [as 别名]
def test_fromtimestamp(self):
        import time

        # Try an arbitrary fixed value.
        year, month, day = 1999, 9, 19
        ts = time.mktime((year, month, day, 0, 0, 0, 0, 0, -1))
        d = self.theclass.fromtimestamp(ts)
        self.assertEqual(d.year, year)
        self.assertEqual(d.month, month)
        self.assertEqual(d.day, day) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_datetime.py

示例2: test_more_ctime

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import mktime [as 别名]
def test_more_ctime(self):
        # Test fields that TestDate doesn't touch.
        import time

        t = self.theclass(2002, 3, 2, 18, 3, 5, 123)
        self.assertEqual(t.ctime(), "Sat Mar  2 18:03:05 2002")
        # Oops!  The next line fails on Win2K under MSVC 6, so it's commented
        # out.  The difference is that t.ctime() produces " 2" for the day,
        # but platform ctime() produces "02" for the day.  According to
        # C99, t.ctime() is correct here.
        # self.assertEqual(t.ctime(), time.ctime(time.mktime(t.timetuple())))

        # So test a case where that difference doesn't matter.
        t = self.theclass(2002, 3, 22, 18, 3, 5, 123)
        self.assertEqual(t.ctime(), time.ctime(time.mktime(t.timetuple()))) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:test_datetime.py


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