Re: The year before the year 1

"Olson, Arthur David (NIH/NCI)" <olsona@dc37a.nci.nih.gov> writes:
it's a localtime/gmtime issue (how to set the value of tm_year for given time_t inputs). In any event...can you point me at chapter on verse from the C standard on this?
The C standard says that the semantics of tm_year is "years since 1900". It gives no normal range limit (unlike other members like tm_mon, where it lists a normal range limit of [0,11]), so presumably the valid values for tm_year are INT_MIN..INT_MAX. However, the standard has no explicit statement that tm_year == -1 stands for 1899, and I guess that one could argue that the word "since" implies a nonnegative value and that the behavior is undefined when tm_year is negative. However, I don't know of any implementation where -1 stands for anything other than 1899 (the only obvious value). If we assume this, then -2 stands for 1898, ..., -1899 stands for the year 1, and -1900 stands for the year 0 (or the year 1 B.C., if you prefer the Venerable Bede's notation). This is true on all implementations that I know of, at least as far as localtime/gmtime goes (typically on 64-bit hosts). For strftime the issue is not so clear: please see my next message.
participants (1)
-
Paul Eggert