Question

From http://www.cplusplus.com/reference/ctime/time_t :

time_t

Alias of a fundamental arithmetic type capable of representing times, as those returned by function time.

For historical reasons, it is generally implemented as an integral value representing the number of seconds elapsed since 00:00 hours, Jan 1, 1970 UTC (i.e., a unix timestamp). Although libraries may implement this type using alternative time representations.

Portable programs should not use values of this type directly, but always rely on calls to elements of the standard library to translate them to portable types.

Does someone know an example of such implementation where std::time_t is not represented as unix time?

Was it helpful?

Solution

Per §17.6.4.3.4/1:

For each type T from the Standard C library,184 the types ::T and std::T are reserved to the implementation and, when defined, ::T shall be identical to std::T.

184 ... time_t ...

So, both time_t and std::time_t are implementation defined types. The hint is somehow correct.

POSIX compatible systems try to implement it as unix time, but POSIX is not based on C++ standard and vice-versa. Maybe a C++ compiler in a specific embedded system will be created at future that has a different time_t...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top