Lines Matching defs:tm
37 * correct out of bounds fields in tm
41 * tm is the return value
45 tmfix(register Tm_t* tm)
58 if (w = !tm->tm_sec && !tm->tm_min && !tm->tm_mday && !tm->tm_year && !tm->tm_yday && !tm->tm_isdst)
60 tm->tm_year = 99;
61 tm->tm_mday = 2;
68 if ((n = tm->tm_nsec) < 0)
70 tm->tm_sec -= (TMX_RESOLUTION - n) / TMX_RESOLUTION;
71 tm->tm_nsec = TMX_RESOLUTION - (-n) % TMX_RESOLUTION;
75 tm->tm_sec += n / TMX_RESOLUTION;
76 tm->tm_nsec %= TMX_RESOLUTION;
78 if ((n = tm->tm_sec) < 0)
80 tm->tm_min -= (60 - n) / 60;
81 tm->tm_sec = 60 - (-n) % 60;
85 tm->tm_min += n / 60;
86 tm->tm_sec %= 60;
88 if ((n = tm->tm_min) < 0)
90 tm->tm_hour -= (60 - n) / 60;
91 n = tm->tm_min = 60 - (-n) % 60;
95 tm->tm_hour += n / 60;
96 tm->tm_min %= 60;
98 if ((n = tm->tm_hour) < 0)
100 tm->tm_mday -= (23 - n) / 24;
101 tm->tm_hour = 24 - (-n) % 24;
105 tm->tm_mday += n / 24;
106 tm->tm_hour %= 24;
108 if (tm->tm_mon >= 12)
110 tm->tm_year += tm->tm_mon / 12;
111 tm->tm_mon %= 12;
113 else if (tm->tm_mon < 0)
115 tm->tm_year--;
116 if ((tm->tm_mon += 12) < 0)
118 tm->tm_year += tm->tm_mon / 12;
119 tm->tm_mon = (-tm->tm_mon) % 12;
122 while (tm->tm_mday < -365)
124 tm->tm_year--;
125 tm->tm_mday += 365 + LEAP(tm);
127 while (tm->tm_mday > 365)
129 tm->tm_mday -= 365 + LEAP(tm);
130 tm->tm_year++;
132 while (tm->tm_mday < 1)
134 if (--tm->tm_mon < 0)
136 tm->tm_mon = 11;
137 tm->tm_year--;
139 tm->tm_mday += DAYS(tm);
141 while (tm->tm_mday > (n = DAYS(tm)))
143 tm->tm_mday -= n;
144 if (++tm->tm_mon > 11)
146 tm->tm_mon = 0;
147 tm->tm_year++;
152 w = tm->tm_wday;
153 t = tmtime(tm, TM_LOCALZONE);
159 tm->tm_wday += w;
160 if ((tm->tm_mday += w) > DAYS(tm))
161 tm->tm_mday -= 7;
164 tm->tm_yday = tm_data.sum[tm->tm_mon] + (tm->tm_mon > 1 && LEAP(tm)) + tm->tm_mday - 1;
165 n = tm->tm_year + 1900 - 1;
166 tm->tm_wday = (n + n / 4 - n / 100 + n / 400 + tm->tm_yday + 1) % 7;
172 return tm;