### September 9th time_t error

greenspun.com : LUSENET : Y2K discussion group : One Thread

 Time_T Discussion

The variable time_t is a standard data type used to store the number of seconds since the standard UNIX Epoch, 00:00:00 January 1, 1970 UTC. When this variable reaches 10 digits (1,000,000,000 seconds), it can be calculated fairly straightforwardly as follows:

Every four years there is a leap year between 1900 and 2100 (but not including 1900 or 2100). In effect, only the first rule for leap-years is at work during this span of years since in the year 2000 both the second and third rules apply which means they cancel each other out.

Starting with every day having 24 hours/day * 60 minutes/hour * 60 seconds/minute = 86,400 seconds/day.

If we divide the time_t ten digit quantity we are interested in (1,000,000,000 seconds) by the number of seconds in a day, we can find out how many days into the UNIX Epoch time_t will hit ten digits. The calculation is as follows:

1,000,000,000 seconds / 86,400 seconds/day = 11,574.074074 days
Using the full days (11,574) part gives us years by dividing 11,574 days by 365 days per year:

31.709589041 years BUT during that time interval there would be 8 leap years so the calculation would actually be:
(11,574 days minus 8) divided by 365 = 31.687671233 years

So we now know that it will be 31 years (with 8 of them being leap years).

This accounts for 11,323 days (31 years * 365 days/year + 8 days) out of the 11,574.074074 days.

So it will be 11,574.074074 - 11,323 = 251.074074 days into the 31st year when time_t reaches 10 digits.

Converting the .074074 days to hours, minutes, and seconds is as follows:

.074074days * 24 hours/day = 1.7777777778 hours

.77777778hours * 60 minutes/hour = 46.666666667 minutes

.666666667minutes * 60 seconds/minute = 40 seconds

So 31 years 251 days 1 hour 46 minutes and 40 seconds into the UNIX Epoch, time_t will go to 10 digits.

31 years after 00:00:00 January 1, 1970 UTC is 2001.

251 days into the year is the 9th of September for non-leap years like 2001.

So time_t will become a 10 digit quantity on September 9th at 1:46:40 a.m. UTC.

Mitre

-- Anonymous, July 22, 2001