c++ - When is std::chrono epoch? -


std::chrono::time_point::time_since_epoch() returns duration, referred time_point in past. when such time_point? depends on c++ implementation or it's defined c++ standard? or de facto standard set epoch 1 january 1970 utc?

it function of both specific clock time_point refers to, , implementation of clock. standard specifies 3 different clocks:

  • system_clock
  • steady_clock
  • high_resolution_clock

and standard not specify epoch of these clocks.

programmers (you) can author own clocks, may or may not specify epoch.

there de-facto (unofficial) standard std::chrono::system_clock::time_point has epoch consistent unix time. defined time duration has elapsed since 00:00:00 coordinated universal time (utc), thursday, 1 january 1970, not counting leap seconds.

fwiw, here date/time library takes advantage of de-facto standard.

there no de-facto standard other 2 std-specified clocks. additionally high_resolution_clock permitted type alias either system_clock or steady_clock.

on os x, high_resolution_clock type alias steady_clock, , steady_clock count of nanoseconds since computer booted (no relationship whatsoever utc).


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -