3 ms·
POSIX defines gettimeofday [1], which fills a timeval with integer (time_t) seconds and integer (suseconds_t) microseconds. Is your concern over weather Unix T
by toast0 8y ago
POSIX defines gettimeofday [1], which fills a timeval with integer (time_t) seconds and integer (suseconds_t) microseconds.
Is your concern over weather Unix Time is a time_t or a timeval?
A time_t shouldn't go backwards (in normal operation), but a timeval does.
[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/gettimeofday.html http://pubs.opengroup.org/onlinepubs/9699919799/functions/ge...
- brmgb 8y ago> Is your concern over weather Unix Time is a time_t or a timeval? Yes, you could put it that way. I view Unix Time as referring strictly to the time_t part (seconds since Epoch) but I might be the one in the wrong. I didn't remember that the timeval part existed in the standard.
- _kst_ 8y agogettimeofday is obsolescent, but its replacement clock_gettime has the same issue. gettimeofday gives you a struct timeval with microsecond resolution. clock_gettime (which takes an extra argument specifying which of several clocks to use) gives you a struct timespec, with nanosecond resolution. https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_gettime.html https://pubs.opengroup.org/onlinepubs/9699919799/functions/c...