我有一个与 Jenkins API (jenkinsapi) 集成的 Django 应用程序。我在 Build 对象上调用 get_timestamp() 方法。在交互模式下,它返回一个日期字符串,如“2013-05-07 09:29:46”;但是,在 Django 中,它返回一个 long,我认为它是一个 Unix 日期时间戳,但它是一个日期,到目前为止,我得到 ValueError: year is out of range。它返回的值是 1368805100576。
>>> b = api.get_jobs()
>>> for job in b:
... last_build = job[1].get_last_build_or_none()
... print last_build.id(), last_build.get_timestamp()
...
3 2013-05-07 09:29:46
2 2013-05-07 09:28:52
并且从非交互模式:
print current_build.get_timestamp()
friendly_timestamp = datetime.datetime.fromtimestamp(int(current_build.get_timestamp())).strftime('%Y-%m-%d %H:%M:%S')
ValueError: year is out of range
知道为什么这些会有所不同以及 get_timestamp 返回的时间有多长吗?