Timestamp out of range for platform localtime()/gmtime() function

后端 未结 2 1749
隐瞒了意图╮
隐瞒了意图╮ 2020-12-11 03:44

I try:

ts = -216345600000
datetime.datetime.fromtimestamp(ts/1000)

ValueError: timestamp out of range for platform localtime()/gmti

2条回答
  •  半阙折子戏
    2020-12-11 04:33

    Maybe slightly less related to the problem from the question but may be applicable to those who want to represent full date-time range without any very specific workarounds to limitations of the default datetime implementation.

    I have checked a few libraries and I suggest using:

    dateparser - for parsing date/time stated naturally for a human being and in multitude of languages.

    arrow - drop-in replacement for datetime without its limitations (e.g. possibility to represent dates before and close to the epoch of 1. year AD).

提交回复
热议问题