Maximum value of timestamp

前端 未结 3 1095
-上瘾入骨i
-上瘾入骨i 2021-01-12 06:38

I am using Python 3.6.0 on Windows 10 x64.

I just found that in time.ctime(seconds), seconds parameter has an implicit maximum value, which

3条回答
  •  一个人的身影
    2021-01-12 06:42

    I'm using 3.6.1 |Continuum Analytics, Inc.| (default, May 11 2017, 13:09:58) \n[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] in a Ubuntu 16.04 VM running on a Windows 10 machine.

    I broke apart your ctime call to its components, to investigate but I don't run into the same maximum.

    >>> time.asctime(time.localtime(32536799999-1))
    'Mon Jan 19 02:59:58 3001'
    >>> time.asctime(time.localtime(32536799999+1))
    'Mon Jan 19 03:00:00 3001'
    >>> time.asctime(time.localtime(32536799999+10))
    'Mon Jan 19 03:00:09 3001'
    >>> time.asctime(time.localtime(32536799999+10000))
    'Mon Jan 19 05:46:39 3001'
    >>> time.asctime(time.localtime(32536799999+1000000))
    'Fri Jan 30 16:46:39 3001'
    >>> time.asctime(time.localtime(32536799999+1000000000))
    'Thu Sep 27 05:46:39 3032'
    >>> time.ctime(32536799999+1000000000)
    'Thu Sep 27 05:46:39 3032'
    >>> time.asctime(time.gmtime(32536799999-1))
    'Mon Jan 19 07:59:58 3001'
    >>> time.asctime(time.gmtime(32536799999+1))
    'Mon Jan 19 08:00:00 3001'
    >>> time.asctime(time.gmtime(32536799999+1000000000))
    'Thu Sep 27 09:46:39 3032'
    

    Either something was fixed from 3.6.0 to 3.6.1, or you have some interesting issue specific to your machine.

    I do see the following time related change in 3.6.1: https://www.python.org/dev/peps/pep-0495/ I wonder if the time you happened to be using happened to fall into a fold or a gap? Could you try adding a little over 1 hour on your system and see if it becomes valid again?

提交回复
热议问题