3 ms·
I think of this another way: why should a "get current time" function ever return an error? And what is someone to do about that case anyway? The time it return
by userbinator 11y ago
I think of this another way: why should a "get current time" function ever return an error? And what is someone to do about that case anyway? The time it returns may be wrong, but I think such a function shouldn't be capable of returning "error", as adding that path just increases complexity needlessly without much additional benefit; with the current time being used often in things like error logging, introducing an "error on top of an error" is not a good idea. Defaulting to January 1, 1970 or December 31, 1969 would be sufficient.
- the_mitsuhiko 11y agoIf you look into the glibc sources you will find time() implemented as always returning -1. Not all systems have a clock. So specifically for linux for instance it will ask the os for the time.