Unix 时间和闰秒 [英] Unix time and leap seconds

查看:16
本文介绍了Unix 时间和闰秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于 Unix (POSIX) 时间,维基百科说:

Regarding Unix (POSIX) time, Wikipedia says:

由于它处理闰秒,它既不是时间的线性表示,也不是 UTC 的真实表示.

Due to its handling of leap seconds, it is neither a linear representation of time nor a true representation of UTC.

但是 Unix date 命令似乎实际上并不知道它们

But the Unix date command does not seem to be aware of them actually

$ date -d '@867715199' --utc
Mon Jun 30 23:59:59 UTC 1997
$ date -d '@867715200' --utc
Tue Jul  1 00:00:00 UTC 1997

虽然在 Mon Jun 30 23:59:60 UTC 1997 应该有一个闰秒.

这是否意味着只有date命令会忽略闰秒,而Unix时间的概念则不会?

Does this mean that only the date command ignores leap seconds, while the concept of Unix time doesn't?

推荐答案

每天的秒数固定 Unix 时间戳.

Unix 时间编号在 Unix 纪元时为零,并且增加了自 epoch 以来,每天正好 86400.

The Unix time number is zero at the Unix epoch, and increases by exactly 86400 per day since the epoch.

所以它不能代表闰秒.操作系统将减慢时钟以适应这种情况.就 Unix 时间戳而言,闰秒根本不存在.

So it cannot represent leap seconds. The OS will slow down the clock to accommodate for this. The leap seconds is simply not existent as far a Unix timestamps are concerned.

这篇关于Unix 时间和闰秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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