3 ms·
Time is signed though so time actually began at 1901-12-13T20:45:52Z.
by bhaak 4y ago
Time is signed though so time actually began at 1901-12-13T20:45:52Z.
- kevin_thibedeau 4y agoUnless your time oracle is NTP in which case time is unsigned starting in 1900.
- bregma 4y agoTime is not guaranteed to be signed. W Hat you have there is undefined behaviour.
- fluoridation 4y agoSurely it's unspecified behavior, at worst.
- bregma 4y agoThe signedness of time_t is unspecified. If you rely on it being signed and overflowing so it goes back to before January 01, 1970, well, that's living on the edge....
- fluoridation 4y agoOnly if your code is intended to be portable. If you know the signedness of time_t in your implementation, there's no harm in assuming it.
- Karellen 4y agoIt's probably more likely to be implementation-defined behaviour (as with the signedness of 'char') rather than undefined behaviour. The third alternative being unspecified behaviour - see comp.lang.c FAQ 11.33 for more info: https://c-faq.com/ansi/undef.html https://c-faq.com/ansi/undef.html
- aidenn0 4y agoOn some systems errno is not set by a failed call to time() in which case the only way to check for an error is if the returned value is (time_t)-1 which makes it impossible to unambiguously represent 1 second before the epoch.