7 #define SEC2HOUR (60L*SEC2MIN)
8 #define SEC2DAY (24L*SEC2HOUR)
11 * days per month plus days/year
15 365, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
17 static int ldmsize[] =
19 366, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
23 * return the days/month for the given year
28 if((y%4) == 0 && ((y%100) != 0 || (y%400) == 0))
35 * compute seconds since Jan 1 1970 GMT
36 * and convert to our timezone.
43 int i, yday, year, *d2m;
50 year = tm->year + 1900;
51 for(i = 1970; i < year; i++){
53 secs += d2m[0] * SEC2DAY;
57 * if mday is set, use mon and mday to compute yday
62 for(i=0; i<tm->mon; i++)
68 secs += yday * SEC2DAY;
71 * hours, minutes, seconds
73 secs += tm->hour * SEC2HOUR;
74 secs += tm->min * SEC2MIN;
78 * Assume the local time zone if zone is not GMT
80 if(strcmp(tm->zone, "GMT") != 0) {
81 i = zonelookuptinfo(&ti0, secs);
86 * to what local time period `secs' belongs?
90 * east of GMT; check previous local time transition
92 if (ti->t+ti->tzoff > secs)
93 if (zonetinfo(&ti1, i-1)!=-1)
97 * west of GMT; check next local time transition
99 if (zonetinfo(&ti1, i+1))
100 if (ti1.t+ti->tzoff < secs)
102 // fprint(2, "tt: %ld+%d %ld\n", (long)ti->t, ti->tzoff, (long)secs);