On Mon, Oct 05, 2020 at 03:16:24PM +0000, Roderick wrote: > > The result of time() has type time_t and we know what kind of number > goes there: seconds since 0 hours, 0 minutes, 0 seconds, January 1, > 1970, Coordinated Universal Time. > > In my FreeBSD running on a 64 bit processor this type is: int (__32_t). > It considers this size enough for above information. > > In my OpenBSD running on a 32 bit processor this type is: long long > (__64_t). > > None of both has an unsigned type, although time moves forward > (more or less fast!!!). > > Is there a reason for this discrepancy? Is there no standard for the > size of time_t? > > And what does mean the types with __? I find it so confusing. :) > > Rod. >
Hi Rod, I don't know for sure but I believe in BSD most system internal variables start with __, they are not meant to be used by the programmer. When time_t was made, I think, positive integers meant time forwards, and negative integers meant time backwards from epoch so that people born in 1938 for example could be processed. There is a song on the openbsd site that "please don't let my time be time32_t" for a time machine because the singer also didn't want to end up in 1912 or so. Which is what 32 bit time_t rolls over to sometime in January 2038(?). On a 32 bit time_t one second past timestamp 2147483647 will wrap it into the negative because it is not unsigned and the 32nd bit in a 32 bit signed integer indicates negative afaik. kite$ dc 2o 2147483648 p 10000000000000000000000000000000 2147483647 p 1111111111111111111111111111111 Regards, -peter