Lines Matching +full:- +full:t
1 /*-
44 { -1, NULL }
50 { -1, NULL }
57 domktime(struct tm *t, char type) in domktime() argument
61 while ((ret = mktime(t)) == -1 && t->tm_year > 68 && t->tm_year < 138) in domktime()
63 adjhour(t, type == '-' ? type : '+', 1, 0); in domktime()
69 trans(const struct trans t[], const char *arg) in trans() argument
73 for (f = 0; t[f].val != -1; f++) in trans()
74 if (!strncasecmp(t[f].str, arg, 3) || in trans()
75 !strncasecmp(t[f].str, arg, strlen(t[f].str))) in trans()
76 return t[f].val; in trans()
78 return -1; in trans()
88 while (v->next) in vary_append()
89 v = v->next; in vary_append()
90 nextp = &v->next; in vary_append()
96 (*nextp)->arg = arg; in vary_append()
97 (*nextp)->next = NULL; in vary_append()
104 daysinmonth(const struct tm *t) in daysinmonth() argument
108 year = t->tm_year + 1900; in daysinmonth()
110 if (t->tm_mon == 1) in daysinmonth()
119 else if (t->tm_mon >= 0 && t->tm_mon < 12) in daysinmonth()
120 return mdays[t->tm_mon]; in daysinmonth()
127 adjyear(struct tm *t, char type, int64_t val, int mk) in adjyear() argument
131 t->tm_year += val; in adjyear()
133 case '-': in adjyear()
134 t->tm_year -= val; in adjyear()
137 t->tm_year = val; in adjyear()
138 if (t->tm_year < 69) in adjyear()
139 t->tm_year += 100; /* as per date.c */ in adjyear()
140 else if (t->tm_year > 1900) in adjyear()
141 t->tm_year -= 1900; /* struct tm holds years since 1900 */ in adjyear()
144 return !mk || domktime(t, type) != -1; in adjyear()
148 adjmon(struct tm *t, char type, int64_t val, int istext, int mk) in adjmon() argument
158 if (val <= t->tm_mon) in adjmon()
159 val += 11 - t->tm_mon; /* early next year */ in adjmon()
161 val -= t->tm_mon + 1; /* later this year */ in adjmon()
164 if (!adjyear(t, '+', (t->tm_mon + val) / 12, 0)) in adjmon()
167 t->tm_mon += val; in adjmon()
168 if (t->tm_mon > 11) in adjmon()
169 t->tm_mon -= 12; in adjmon()
173 case '-': in adjmon()
175 if (val-1 > t->tm_mon) in adjmon()
176 val = 13 - val + t->tm_mon; /* later last year */ in adjmon()
178 val = t->tm_mon - val + 1; /* early this year */ in adjmon()
181 if (!adjyear(t, '-', val / 12, 0)) in adjmon()
184 if (val > t->tm_mon) { in adjmon()
185 if (!adjyear(t, '-', 1, 0)) in adjmon()
187 val -= 12; in adjmon()
189 t->tm_mon -= val; in adjmon()
196 t->tm_mon = --val; in adjmon()
199 /* e.g., -v-1m on March, 31 is the last day of February in common sense */ in adjmon()
200 lmdays = daysinmonth(t); in adjmon()
201 if (t->tm_mday > lmdays) in adjmon()
202 t->tm_mday = lmdays; in adjmon()
204 return !mk || domktime(t, type) != -1; in adjmon()
208 adjday(struct tm *t, char type, int64_t val, int mk) in adjday() argument
215 lmdays = daysinmonth(t); in adjday()
216 if (val > lmdays - t->tm_mday) { in adjday()
217 val -= lmdays - t->tm_mday + 1; in adjday()
218 t->tm_mday = 1; in adjday()
219 if (!adjmon(t, '+', 1, 0, 0)) in adjday()
222 t->tm_mday += val; in adjday()
227 case '-': in adjday()
229 if (val >= t->tm_mday) { in adjday()
230 val -= t->tm_mday; in adjday()
231 t->tm_mday = 1; in adjday()
232 if (!adjmon(t, '-', 1, 0, 0)) in adjday()
234 t->tm_mday = daysinmonth(t); in adjday()
236 t->tm_mday -= val; in adjday()
241 if (val > 0 && val <= daysinmonth(t)) in adjday()
242 t->tm_mday = val; in adjday()
248 return !mk || domktime(t, type) != -1; in adjday()
252 adjwday(struct tm *t, char type, int64_t val, int istext, int mk) in adjwday() argument
260 if (val < t->tm_wday) in adjwday()
261 val = 7 - t->tm_wday + val; /* early next week */ in adjwday()
263 val -= t->tm_wday; /* later this week */ in adjwday()
265 val *= 7; /* "-v+5w" == "5 weeks in the future" */ in adjwday()
266 return !val || adjday(t, '+', val, mk); in adjwday()
267 case '-': in adjwday()
269 if (val > t->tm_wday) in adjwday()
270 val = 7 - val + t->tm_wday; /* later last week */ in adjwday()
272 val = t->tm_wday - val; /* early this week */ in adjwday()
274 val *= 7; /* "-v-5w" == "5 weeks ago" */ in adjwday()
275 return !val || adjday(t, '-', val, mk); in adjwday()
277 if (val < t->tm_wday) in adjwday()
278 return adjday(t, '-', t->tm_wday - val, mk); in adjwday()
281 else if (val > t->tm_wday) in adjwday()
282 return adjday(t, '+', val - t->tm_wday, mk); in adjwday()
288 adjhour(struct tm *t, char type, int64_t val, int mk) in adjhour() argument
298 days = (t->tm_hour + val) / 24; in adjhour()
300 t->tm_hour += val; in adjhour()
301 t->tm_hour %= 24; in adjhour()
302 if (!adjday(t, '+', days, 0)) in adjhour()
307 case '-': in adjhour()
313 if (val > t->tm_hour) { in adjhour()
315 val -= 24; in adjhour()
317 t->tm_hour -= val; in adjhour()
318 if (!adjday(t, '-', days, 0)) in adjhour()
326 t->tm_hour = val; in adjhour()
329 return !mk || domktime(t, type) != -1; in adjhour()
333 adjmin(struct tm *t, char type, int64_t val, int mk) in adjmin() argument
341 if (!adjhour(t, '+', (t->tm_min + val) / 60, 0)) in adjmin()
344 t->tm_min += val; in adjmin()
345 if (t->tm_min > 59) in adjmin()
346 t->tm_min -= 60; in adjmin()
350 case '-': in adjmin()
352 if (!adjhour(t, '-', val / 60, 0)) in adjmin()
355 if (val > t->tm_min) { in adjmin()
356 if (!adjhour(t, '-', 1, 0)) in adjmin()
358 val -= 60; in adjmin()
360 t->tm_min -= val; in adjmin()
367 t->tm_min = val; in adjmin()
370 return !mk || domktime(t, type) != -1; in adjmin()
374 adjsec(struct tm *t, char type, int64_t val, int mk) in adjsec() argument
382 if (!adjmin(t, '+', (t->tm_sec + val) / 60, 0)) in adjsec()
385 t->tm_sec += val; in adjsec()
386 if (t->tm_sec > 59) in adjsec()
387 t->tm_sec -= 60; in adjsec()
391 case '-': in adjsec()
393 if (!adjmin(t, '-', val / 60, 0)) in adjsec()
396 if (val > t->tm_sec) { in adjsec()
397 if (!adjmin(t, '-', 1, 0)) in adjsec()
399 val -= 60; in adjsec()
401 t->tm_sec -= val; in adjsec()
408 t->tm_sec = val; in adjsec()
411 return !mk || domktime(t, type) != -1; in adjsec()
415 vary_apply(const struct vary *v, struct tm *t) in vary_apply() argument
423 for (; v; v = v->next) { in vary_apply()
424 type = *v->arg; in vary_apply()
425 arg = v->arg; in vary_apply()
426 if (type == '+' || type == '-') in vary_apply()
435 t->tm_isdst = -1; in vary_apply()
437 if (strspn(arg, digits) != len-1) { in vary_apply()
439 if (val != -1) { in vary_apply()
440 if (!adjwday(t, type, val, 1, 1)) in vary_apply()
444 if (val != -1) { in vary_apply()
445 if (!adjmon(t, type, val, 1, 1)) in vary_apply()
452 which = arg[len-1]; in vary_apply()
456 if (!adjsec(t, type, val, 1)) in vary_apply()
460 if (!adjmin(t, type, val, 1)) in vary_apply()
464 if (!adjhour(t, type, val, 1)) in vary_apply()
468 t->tm_isdst = -1; in vary_apply()
469 if (!adjday(t, type, val, 1)) in vary_apply()
473 t->tm_isdst = -1; in vary_apply()
474 if (!adjwday(t, type, val, 0, 1)) in vary_apply()
478 t->tm_isdst = -1; in vary_apply()
479 if (!adjmon(t, type, val, 0, 1)) in vary_apply()
483 t->tm_isdst = -1; in vary_apply()
484 if (!adjyear(t, type, val, 1)) in vary_apply()
501 n = v->next; in vary_destroy()