本文介绍了什么时候std :: chrono epoch?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

std :: chrono :: time_point :: time_since_epoch()返回持续时间,引用一些 time_point 过去。什么时候这样的 time_point ?它取决于C ++实现或者它是由C ++标准定义的?或者,它是一个事实上的标准,将时代设置为1970年1月1日UTC?

std::chrono::time_point::time_since_epoch() returns a duration, referred to some time_point in the past. When is such a time_point? It depends on the C++ implementation or it's defined by the C++ standard? Or it is a de facto standard to set the epoch to 1 January 1970 UTC?

推荐答案

clock 指向 time_point ,并执行 clock 。该标准指定了三个不同的时钟:

It is a function of both the specific clock the time_point refers to, and the implementation of that clock. The standard specifies three different clocks:


  • system_clock

  • steady_clock

  • high_resolution_clock

  • system_clock
  • steady_clock
  • high_resolution_clock

标准没有指定任何时钟的纪元。

And the standard does not specify the epoch for any of these clocks.

程序员

有一个事实上的(非官方的)标准 std :: chrono :: system_clock :: time_point 有与一致的纪元。这是定义为自世界协调时间(UTC)(1970年1月1日星期四)00:00:00起,不计算闰秒的时间长度。

There is a de-facto (unofficial) standard that std::chrono::system_clock::time_point has an epoch consistent with Unix Time. This is defined as the time duration that has elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap seconds.

Fwiw ,,利用了这个事实上的标准。

Fwiw, here is a date/time library which takes advantage of this de-facto standard.

其他两个std指定的时钟没有事实上的标准。此外, high_resolution_clock 可以是 system_clock steady_clock

There is no de-facto standard for the other two std-specified clocks. Additionally high_resolution_clock is permitted to be a type alias for either system_clock or steady_clock.

在OS X上, high_resolution_clock / code>, steady_clock 是计算机启动后的毫微秒数(与UTC无关)。

On OS X, high_resolution_clock is a type alias for steady_clock, and steady_clock is a count of nanoseconds since the computer booted (no relationship whatsoever to UTC).

这篇关于什么时候std :: chrono epoch?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 19:38