> Then how can we represent the time "0.5 seconds before the epoch"?
This is indeed a mis-design AFAICT. It may be my fault.
Possible fixes:
- The nanoseconds are unsigned but always go toward the future.
- The nanoseconds are signed.
POSIX says:
The <time.h> header shall declare the timespec structure, which shall
include at least the following members:
time_t tv_sec Seconds.
long tv_nsec Nanoseconds.
So in POSIX nanoseconds are signed.
I haven't tested what stat() returns when it encounters a file whose
timestamp is earlier than the Unix epoch. (Several types of file system
support those.)