python time.time()和“夏令时”; [英] python time.time() and "Daylight Saving Time"

查看:239
本文介绍了python time.time()和“夏令时”;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行python(Windows或Linux)
的计算机的时钟自动更改并且调用 time.time()会发生什么?

What happens when the clock of the computer running python (Windows or Linux) gets automatically changed and a call time.time()?

我读到,当手动将时钟更改为某个值时, time.time()的值会变小

I've read that the value of time.time() will be smaller when the clock is changed manually to some value in the past.

推荐答案

time.time() 文档状态:

返回自纪元以来的时间(以秒为单位)为浮点数。

Return the time in seconds since the epoch as a floating point number.

此处提到的特定时期是 Unix时代,即1970年1月1日午夜 UTC

The particular epoch referred to here is the Unix epoch, which is Midnight, Jan 1st 1970 UTC.

因为它总是基于UTC,它不会受到更改计算机时区的影响,也不会受到计算机时区进入或退出夏令时的影响。

Since it is always based on UTC, it will not be affected by changing the computer's time zone, nor when the computer's time zone enters or exits daylight saving time.

该功能确实依赖提供价值的基础实现,这些实现总是以UTC的形式返回值-与操作系统无关。

Though the function does rely on the underlying implementation to provide the value, those implementations always return values in terms of UTC - regardless of operating system.

特别是在Windows上,它最终称为 GetSystemTimeAsFileTime OS函数,以UTC形式返回其值。不受时区选择或时区中DST更改的影响。

On Windows in particular, it ultimately calls the GetSystemTimeAsFileTime OS function, which returns its value in terms of UTC. It is not affected by time zone selection or by DST changes within the time zone.

这篇关于python time.time()和“夏令时”;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆