Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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/ge...



> 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.


gettimeofday 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/c...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: