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


Python time.gmtime方法代码示例

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


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

示例1: fromtimestamp

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import gmtime [as 别名]
def fromtimestamp(timestamp, tz=None):
        """Return the local date and time corresponding to the POSIX timestamp.

        Same as is returned by time.time(). If optional argument tz is None or
        not specified, the timestamp is converted to the platform's local date
        and time, and the returned datetime object is naive.

        Else tz must be an instance of a class tzinfo subclass, and the
        timestamp is converted to tz's time zone. In this case the result is
        equivalent to
        ``tz.fromutc(datetime.utcfromtimestamp(timestamp).replace(tzinfo=tz))``.

        fromtimestamp() may raise `ValueError`, if the timestamp is out of the
        range of values supported by the platform C localtime() or gmtime()
        functions. It's common for this to be restricted to years in 1970
        through 2038. Note that on non-POSIX systems that include leap seconds
        in their notion of a timestamp, leap seconds are ignored by
        fromtimestamp(), and then it's possible to have two timestamps
        differing by a second that yield identical datetime objects.

        .. seealso:: `utcfromtimestamp`.
        """ 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:24,代码来源:idatetime.py

示例2: test_utcfromtimestamp

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

        ts = time.time()
        expected = time.gmtime(ts)
        got = self.theclass.utcfromtimestamp(ts)
        self.verify_field_equality(expected, got) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_datetime.py

示例3: test_utcfromtimestamp

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

        ts = time.time()
        expected = time.gmtime(ts)
        got = self.theclass.utcfromtimestamp(ts)
        self.verify_field_equality(expected, got)

    # Run with US-style DST rules: DST begins 2 a.m. on second Sunday in
    # March (M3.2.0) and ends 2 a.m. on first Sunday in November (M11.1.0). 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:12,代码来源:datetimetester.py

示例4: test_microsecond_rounding

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import gmtime [as 别名]
def test_microsecond_rounding(self):
        for fts in [self.theclass.fromtimestamp,
                    self.theclass.utcfromtimestamp]:
            zero = fts(0)
            self.assertEqual(zero.second, 0)
            self.assertEqual(zero.microsecond, 0)
            one = fts(1e-6)
            try:
                minus_one = fts(-1e-6)
            except OSError:
                # localtime(-1) and gmtime(-1) is not supported on Windows
                pass
            else:
                self.assertEqual(minus_one.second, 59)
                self.assertEqual(minus_one.microsecond, 999999)

                t = fts(-1e-8)
                self.assertEqual(t, zero)
                t = fts(-9e-7)
                self.assertEqual(t, minus_one)
                t = fts(-1e-7)
                self.assertEqual(t, zero)
                t = fts(-1/2**7)
                self.assertEqual(t.second, 59)
                self.assertEqual(t.microsecond, 992188)

            t = fts(1e-7)
            self.assertEqual(t, zero)
            t = fts(9e-7)
            self.assertEqual(t, one)
            t = fts(0.99999949)
            self.assertEqual(t.second, 0)
            self.assertEqual(t.microsecond, 999999)
            t = fts(0.9999999)
            self.assertEqual(t.second, 1)
            self.assertEqual(t.microsecond, 0)
            t = fts(1/2**7)
            self.assertEqual(t.second, 0)
            self.assertEqual(t.microsecond, 7812) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:41,代码来源:datetimetester.py

示例5: utcfromtimestamp

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import gmtime [as 别名]
def utcfromtimestamp(timestamp):
        """Return the UTC datetime from the POSIX timestamp with tzinfo None.

        This may raise `ValueError`, if the timestamp is out of the range of
        values supported by the platform C ``gmtime()`` function. It's common for
        this to be restricted to years in 1970 through 2038.

        .. seealso:: `fromtimestamp`.
        """ 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:11,代码来源:idatetime.py

示例6: utctimetuple

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import gmtime [as 别名]
def utctimetuple():
        """Return UTC time tuple compatilble with `time.gmtime`.""" 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:4,代码来源:idatetime.py


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