python计算夏令时的具体日期,python time.time()和“夏令时”;

What happens when the clock of the computer running python (Windows or Linux)

gets automatically changed and a call 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() docs state:

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

The particular epoch referred to here is the Unix epoch, which is Midnight, Jan 1st 1970 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.

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.

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值