prev up next   top/contents search

comp.lang.c FAQ list · Question 13.14b

Q: Did C have any Year 2000 problems?


A: No, although poorly-written C programs might have.

The tm_year field of struct tm holds the value of the year minus 1900; this field therefore contains the value 100 for the year 2000. Code that uses tm_year correctly (by adding or subtracting 1900 when converting to or from human-readable 4-digit year representations) has no problems at the turn of the millennium. Any code that used tm_year incorrectly, however, such as by using it directly as a human-readable 2-digit year, or setting it from a 4-digit year with code like

	tm.tm_year = yyyy % 100;	/* WRONG */
or printing it as an allegedly human-readable 4-digit year with code like
	printf("19%d", tm.tm_year);	/* WRONG */
would have had grave y2k problems indeed. See also question 20.32.

(The y2k problem is now mostly old history; all we have left to do is fix all the 32-bit time_t problems by 2038...)

References: K&R2 Sec. B10 p. 255
ISO Sec. 7.12.1
H&S Sec. 18.4 p. 401


prev up next   contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North