Lines Matching refs:time
149 static void do_adjust_for_weekday(timelib_time* time) in do_adjust_for_weekday() argument
153 current_dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_for_weekday()
154 if (time->relative.weekday_behavior == 2) in do_adjust_for_weekday()
157 if (current_dow == 0 && time->relative.weekday != 0) { in do_adjust_for_weekday()
158 time->relative.weekday -= 7; in do_adjust_for_weekday()
163 if (time->relative.weekday == 0 && current_dow != 0) { in do_adjust_for_weekday()
164 time->relative.weekday = 7; in do_adjust_for_weekday()
167 time->d -= current_dow; in do_adjust_for_weekday()
168 time->d += time->relative.weekday; in do_adjust_for_weekday()
171 difference = time->relative.weekday - current_dow; in do_adjust_for_weekday()
172 …if ((time->relative.d < 0 && difference < 0) || (time->relative.d >= 0 && difference <= -time->rel… in do_adjust_for_weekday()
175 if (time->relative.weekday >= 0) { in do_adjust_for_weekday()
176 time->d += difference; in do_adjust_for_weekday()
178 time->d -= (7 - (abs(time->relative.weekday) - current_dow)); in do_adjust_for_weekday()
180 time->relative.have_weekday_relative = 0; in do_adjust_for_weekday()
197 static void magic_date_calc(timelib_time *time) in magic_date_calc() argument
202 if (time->d < -719498) { in magic_date_calc()
206 g = time->d + EPOCH_DAY - 1; in magic_date_calc()
218 time->y = y; in magic_date_calc()
219 time->m = mm; in magic_date_calc()
220 time->d = dd; in magic_date_calc()
223 void timelib_do_normalize(timelib_time* time) in timelib_do_normalize() argument
225 if (time->us != TIMELIB_UNSET) do_range_limit(0, 1000000, 1000000, &time->us, &time->s); in timelib_do_normalize()
226 if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->s, &time->i); in timelib_do_normalize()
227 if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->i, &time->h); in timelib_do_normalize()
228 if (time->s != TIMELIB_UNSET) do_range_limit(0, 24, 24, &time->h, &time->d); in timelib_do_normalize()
229 do_range_limit(1, 13, 12, &time->m, &time->y); in timelib_do_normalize()
232 if (time->y == 1970 && time->m == 1 && time->d != 1) { in timelib_do_normalize()
233 magic_date_calc(time); in timelib_do_normalize()
236 do {} while (do_range_limit_days(&time->y, &time->m, &time->d)); in timelib_do_normalize()
237 do_range_limit(1, 13, 12, &time->m, &time->y); in timelib_do_normalize()
240 static void do_adjust_relative(timelib_time* time) in do_adjust_relative() argument
242 if (time->relative.have_weekday_relative) { in do_adjust_relative()
243 do_adjust_for_weekday(time); in do_adjust_relative()
245 timelib_do_normalize(time); in do_adjust_relative()
247 if (time->have_relative) { in do_adjust_relative()
248 time->us += time->relative.us; in do_adjust_relative()
250 time->s += time->relative.s; in do_adjust_relative()
251 time->i += time->relative.i; in do_adjust_relative()
252 time->h += time->relative.h; in do_adjust_relative()
254 time->d += time->relative.d; in do_adjust_relative()
255 time->m += time->relative.m; in do_adjust_relative()
256 time->y += time->relative.y; in do_adjust_relative()
259 switch (time->relative.first_last_day_of) { in do_adjust_relative()
261 time->d = 1; in do_adjust_relative()
264 time->d = 0; in do_adjust_relative()
265 time->m++; in do_adjust_relative()
269 timelib_do_normalize(time); in do_adjust_relative()
272 static void do_adjust_special_weekday(timelib_time* time) in do_adjust_special_weekday() argument
276 count = time->relative.special.amount; in do_adjust_special_weekday()
277 dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_special_weekday()
280 time->d += (count / 5) * 7; in do_adjust_special_weekday()
289 time->d -= 2; in do_adjust_special_weekday()
291 time->d -= 1; in do_adjust_special_weekday()
296 time->d += 1; in do_adjust_special_weekday()
300 time->d += 2; in do_adjust_special_weekday()
308 time->d += 2; in do_adjust_special_weekday()
310 time->d += 1; in do_adjust_special_weekday()
313 time->d -= 1; in do_adjust_special_weekday()
315 time->d -= 2; in do_adjust_special_weekday()
319 time->d += rem; in do_adjust_special_weekday()
322 static void do_adjust_special(timelib_time* time) in do_adjust_special() argument
324 if (time->relative.have_special_relative) { in do_adjust_special()
325 switch (time->relative.special.type) { in do_adjust_special()
327 do_adjust_special_weekday(time); in do_adjust_special()
331 timelib_do_normalize(time); in do_adjust_special()
332 memset(&(time->relative.special), 0, sizeof(time->relative.special)); in do_adjust_special()
335 static void do_adjust_special_early(timelib_time* time) in do_adjust_special_early() argument
337 if (time->relative.have_special_relative) { in do_adjust_special_early()
338 switch (time->relative.special.type) { in do_adjust_special_early()
340 time->d = 1; in do_adjust_special_early()
341 time->m += time->relative.m; in do_adjust_special_early()
342 time->relative.m = 0; in do_adjust_special_early()
345 time->d = 1; in do_adjust_special_early()
346 time->m += time->relative.m + 1; in do_adjust_special_early()
347 time->relative.m = 0; in do_adjust_special_early()
351 switch (time->relative.first_last_day_of) { in do_adjust_special_early()
353 time->d = 1; in do_adjust_special_early()
356 time->d = 0; in do_adjust_special_early()
357 time->m++; in do_adjust_special_early()
360 timelib_do_normalize(time); in do_adjust_special_early()
494 void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi) in timelib_update_ts() argument
498 do_adjust_special_early(time); in timelib_update_ts()
499 do_adjust_relative(time); in timelib_update_ts()
500 do_adjust_special(time); in timelib_update_ts()
501 res += do_years(time->y); in timelib_update_ts()
502 res += do_months(time->m, time->y); in timelib_update_ts()
503 res += do_days(time->d); in timelib_update_ts()
504 res += do_time(time->h, time->i, time->s); in timelib_update_ts()
505 time->sse = res; in timelib_update_ts()
507 res += do_adjust_timezone(time, tzi); in timelib_update_ts()
508 time->sse = res; in timelib_update_ts()
510 time->sse_uptodate = 1; in timelib_update_ts()
511 …time->have_relative = time->relative.have_weekday_relative = time->relative.have_special_relative … in timelib_update_ts()
518 timelib_time time;
520 time = timelib_strtotime("10 Feb 2005 06:07:03 PM CET"); /* 1108055223 */
522 time.y, time.m, time.d, time.h, time.i, time.s, time.f, time.z, time.dst);
523 if (time.have_relative) {
525 …time.relative.y, time.relative.m, time.relative.d, time.relative.h, time.relative.i, time.relative…
527 if (time.have_weekday_relative) {
528 printf (" / %d", time.relative.weekday);
530 res = time2unixtime(&time);