Lines Matching refs:time
154 static void do_adjust_for_weekday(timelib_time* time) in do_adjust_for_weekday() argument
158 current_dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_for_weekday()
159 if (time->relative.weekday_behavior == 2) in do_adjust_for_weekday()
162 if (current_dow == 0 && time->relative.weekday != 0) { in do_adjust_for_weekday()
163 time->relative.weekday -= 7; in do_adjust_for_weekday()
168 if (time->relative.weekday == 0 && current_dow != 0) { in do_adjust_for_weekday()
169 time->relative.weekday = 7; in do_adjust_for_weekday()
172 time->d -= current_dow; in do_adjust_for_weekday()
173 time->d += time->relative.weekday; in do_adjust_for_weekday()
176 difference = time->relative.weekday - current_dow; in do_adjust_for_weekday()
177 …if ((time->relative.d < 0 && difference < 0) || (time->relative.d >= 0 && difference <= -time->rel… in do_adjust_for_weekday()
180 if (time->relative.weekday >= 0) { in do_adjust_for_weekday()
181 time->d += difference; in do_adjust_for_weekday()
183 time->d -= (7 - (abs(time->relative.weekday) - current_dow)); in do_adjust_for_weekday()
185 time->relative.have_weekday_relative = 0; in do_adjust_for_weekday()
200 static void magic_date_calc(timelib_time *time) in magic_date_calc() argument
205 if (time->d < -719498) { in magic_date_calc()
209 g = time->d + HINNANT_EPOCH_SHIFT - 1; in magic_date_calc()
221 time->y = y; in magic_date_calc()
222 time->m = mm; in magic_date_calc()
223 time->d = dd; in magic_date_calc()
226 void timelib_do_normalize(timelib_time* time) in timelib_do_normalize() argument
228 if (time->us != TIMELIB_UNSET) do_range_limit(0, 1000000, 1000000, &time->us, &time->s); in timelib_do_normalize()
229 if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->s, &time->i); in timelib_do_normalize()
230 if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->i, &time->h); in timelib_do_normalize()
231 if (time->s != TIMELIB_UNSET) do_range_limit(0, 24, 24, &time->h, &time->d); in timelib_do_normalize()
232 do_range_limit(1, 13, 12, &time->m, &time->y); in timelib_do_normalize()
235 if (time->y == 1970 && time->m == 1 && time->d != 1) { in timelib_do_normalize()
236 magic_date_calc(time); in timelib_do_normalize()
239 do {} while (do_range_limit_days(&time->y, &time->m, &time->d)); in timelib_do_normalize()
240 do_range_limit(1, 13, 12, &time->m, &time->y); in timelib_do_normalize()
243 static void do_adjust_relative(timelib_time* time) in do_adjust_relative() argument
245 if (time->relative.have_weekday_relative) { in do_adjust_relative()
246 do_adjust_for_weekday(time); in do_adjust_relative()
248 timelib_do_normalize(time); in do_adjust_relative()
250 if (time->have_relative) { in do_adjust_relative()
251 time->us += time->relative.us; in do_adjust_relative()
253 time->s += time->relative.s; in do_adjust_relative()
254 time->i += time->relative.i; in do_adjust_relative()
255 time->h += time->relative.h; in do_adjust_relative()
257 time->d += time->relative.d; in do_adjust_relative()
258 time->m += time->relative.m; in do_adjust_relative()
259 time->y += time->relative.y; in do_adjust_relative()
262 switch (time->relative.first_last_day_of) { in do_adjust_relative()
264 time->d = 1; in do_adjust_relative()
267 time->d = 0; in do_adjust_relative()
268 time->m++; in do_adjust_relative()
272 timelib_do_normalize(time); in do_adjust_relative()
275 static void do_adjust_special_weekday(timelib_time* time) in do_adjust_special_weekday() argument
279 count = time->relative.special.amount; in do_adjust_special_weekday()
280 dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_special_weekday()
283 time->d += (count / 5) * 7; in do_adjust_special_weekday()
292 time->d -= 2; in do_adjust_special_weekday()
294 time->d -= 1; in do_adjust_special_weekday()
299 time->d += 1; in do_adjust_special_weekday()
303 time->d += 2; in do_adjust_special_weekday()
311 time->d += 2; in do_adjust_special_weekday()
313 time->d += 1; in do_adjust_special_weekday()
316 time->d -= 1; in do_adjust_special_weekday()
318 time->d -= 2; in do_adjust_special_weekday()
322 time->d += rem; in do_adjust_special_weekday()
325 static void do_adjust_special(timelib_time* time) in do_adjust_special() argument
327 if (time->relative.have_special_relative) { in do_adjust_special()
328 switch (time->relative.special.type) { in do_adjust_special()
330 do_adjust_special_weekday(time); in do_adjust_special()
334 timelib_do_normalize(time); in do_adjust_special()
335 memset(&(time->relative.special), 0, sizeof(time->relative.special)); in do_adjust_special()
338 static void do_adjust_special_early(timelib_time* time) in do_adjust_special_early() argument
340 if (time->relative.have_special_relative) { in do_adjust_special_early()
341 switch (time->relative.special.type) { in do_adjust_special_early()
343 time->d = 1; in do_adjust_special_early()
344 time->m += time->relative.m; in do_adjust_special_early()
345 time->relative.m = 0; in do_adjust_special_early()
348 time->d = 1; in do_adjust_special_early()
349 time->m += time->relative.m + 1; in do_adjust_special_early()
350 time->relative.m = 0; in do_adjust_special_early()
354 switch (time->relative.first_last_day_of) { in do_adjust_special_early()
356 time->d = 1; in do_adjust_special_early()
359 time->d = 0; in do_adjust_special_early()
360 time->m++; in do_adjust_special_early()
363 timelib_do_normalize(time); in do_adjust_special_early()
453 timelib_sll timelib_epoch_days_from_time(timelib_time *time) in timelib_epoch_days_from_time() argument
455 timelib_sll y = time->y; // Make copy, as we don't want to change the original one in timelib_epoch_days_from_time()
458 y -= time->m <= 2; in timelib_epoch_days_from_time()
461 …day_of_year = (153 * (time->m + (time->m > 2 ? -3 : 9)) + 2)/5 + time->d - 1; // [… in timelib_epoch_days_from_time()
467 void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi) in timelib_update_ts() argument
469 do_adjust_special_early(time); in timelib_update_ts()
470 do_adjust_relative(time); in timelib_update_ts()
471 do_adjust_special(time); in timelib_update_ts()
479 time->sse = timelib_hms_to_seconds(time->h, time->i, time->s); in timelib_update_ts()
480 time->sse += timelib_epoch_days_from_time(time) * (SECS_PER_DAY / 2); in timelib_update_ts()
481 time->sse += timelib_epoch_days_from_time(time) * (SECS_PER_DAY / 2); in timelib_update_ts()
484 do_adjust_timezone(time, tzi); in timelib_update_ts()
486 time->sse_uptodate = 1; in timelib_update_ts()
487 …time->have_relative = time->relative.have_weekday_relative = time->relative.have_special_relative … in timelib_update_ts()
494 timelib_time time;
496 time = timelib_strtotime("10 Feb 2005 06:07:03 PM CET"); /* 1108055223 */
498 time.y, time.m, time.d, time.h, time.i, time.s, time.f, time.z, time.dst);
499 if (time.have_relative) {
501 …time.relative.y, time.relative.m, time.relative.d, time.relative.h, time.relative.i, time.relative…
503 if (time.have_weekday_relative) {
504 printf (" / %d", time.relative.weekday);
506 res = time2unixtime(&time);