Lines Matching refs:time

145 static void do_adjust_for_weekday(timelib_time* time)  in do_adjust_for_weekday()  argument
149 current_dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_for_weekday()
150 if (time->relative.weekday_behavior == 2) in do_adjust_for_weekday()
153 if (current_dow == 0 && time->relative.weekday != 0) { in do_adjust_for_weekday()
154 time->relative.weekday -= 7; in do_adjust_for_weekday()
159 if (time->relative.weekday == 0 && current_dow != 0) { in do_adjust_for_weekday()
160 time->relative.weekday = 7; in do_adjust_for_weekday()
163 time->d -= current_dow; in do_adjust_for_weekday()
164 time->d += time->relative.weekday; in do_adjust_for_weekday()
167 difference = time->relative.weekday - current_dow; in do_adjust_for_weekday()
168 …if ((time->relative.d < 0 && difference < 0) || (time->relative.d >= 0 && difference <= -time->rel… in do_adjust_for_weekday()
171 if (time->relative.weekday >= 0) { in do_adjust_for_weekday()
172 time->d += difference; in do_adjust_for_weekday()
174 time->d -= (7 - (abs(time->relative.weekday) - current_dow)); in do_adjust_for_weekday()
176 time->relative.have_weekday_relative = 0; in do_adjust_for_weekday()
191 static void magic_date_calc(timelib_time *time) in magic_date_calc() argument
196 if (time->d < -719498) { in magic_date_calc()
200 g = time->d + HINNANT_EPOCH_SHIFT - 1; in magic_date_calc()
212 time->y = y; in magic_date_calc()
213 time->m = mm; in magic_date_calc()
214 time->d = dd; in magic_date_calc()
217 void timelib_do_normalize(timelib_time* time) in timelib_do_normalize() argument
219 if (time->us != TIMELIB_UNSET) do_range_limit(0, 1000000, 1000000, &time->us, &time->s); in timelib_do_normalize()
220 if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->s, &time->i); in timelib_do_normalize()
221 if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->i, &time->h); in timelib_do_normalize()
222 if (time->s != TIMELIB_UNSET) do_range_limit(0, 24, 24, &time->h, &time->d); in timelib_do_normalize()
223 do_range_limit(1, 13, 12, &time->m, &time->y); in timelib_do_normalize()
226 if (time->y == 1970 && time->m == 1 && time->d != 1) { in timelib_do_normalize()
227 magic_date_calc(time); in timelib_do_normalize()
230 do {} while (do_range_limit_days(&time->y, &time->m, &time->d)); in timelib_do_normalize()
231 do_range_limit(1, 13, 12, &time->m, &time->y); in timelib_do_normalize()
234 static void do_adjust_relative(timelib_time* time) in do_adjust_relative() argument
236 if (time->relative.have_weekday_relative) { in do_adjust_relative()
237 do_adjust_for_weekday(time); in do_adjust_relative()
239 timelib_do_normalize(time); in do_adjust_relative()
241 if (time->have_relative) { in do_adjust_relative()
242 time->us += time->relative.us; in do_adjust_relative()
244 time->s += time->relative.s; in do_adjust_relative()
245 time->i += time->relative.i; in do_adjust_relative()
246 time->h += time->relative.h; in do_adjust_relative()
248 time->d += time->relative.d; in do_adjust_relative()
249 time->m += time->relative.m; in do_adjust_relative()
250 time->y += time->relative.y; in do_adjust_relative()
253 switch (time->relative.first_last_day_of) { in do_adjust_relative()
255 time->d = 1; in do_adjust_relative()
258 time->d = 0; in do_adjust_relative()
259 time->m++; in do_adjust_relative()
263 timelib_do_normalize(time); in do_adjust_relative()
266 static void do_adjust_special_weekday(timelib_time* time) in do_adjust_special_weekday() argument
270 count = time->relative.special.amount; in do_adjust_special_weekday()
271 dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_special_weekday()
274 time->d += (count / 5) * 7; in do_adjust_special_weekday()
283 time->d -= 2; in do_adjust_special_weekday()
285 time->d -= 1; in do_adjust_special_weekday()
290 time->d += 1; in do_adjust_special_weekday()
294 time->d += 2; in do_adjust_special_weekday()
302 time->d += 2; in do_adjust_special_weekday()
304 time->d += 1; in do_adjust_special_weekday()
307 time->d -= 1; in do_adjust_special_weekday()
309 time->d -= 2; in do_adjust_special_weekday()
313 time->d += rem; in do_adjust_special_weekday()
316 static void do_adjust_special(timelib_time* time) in do_adjust_special() argument
318 if (time->relative.have_special_relative) { in do_adjust_special()
319 switch (time->relative.special.type) { in do_adjust_special()
321 do_adjust_special_weekday(time); in do_adjust_special()
325 timelib_do_normalize(time); in do_adjust_special()
326 memset(&(time->relative.special), 0, sizeof(time->relative.special)); in do_adjust_special()
329 static void do_adjust_special_early(timelib_time* time) in do_adjust_special_early() argument
331 if (time->relative.have_special_relative) { in do_adjust_special_early()
332 switch (time->relative.special.type) { in do_adjust_special_early()
334 time->d = 1; in do_adjust_special_early()
335 time->m += time->relative.m; in do_adjust_special_early()
336 time->relative.m = 0; in do_adjust_special_early()
339 time->d = 1; in do_adjust_special_early()
340 time->m += time->relative.m + 1; in do_adjust_special_early()
341 time->relative.m = 0; in do_adjust_special_early()
345 switch (time->relative.first_last_day_of) { in do_adjust_special_early()
347 time->d = 1; in do_adjust_special_early()
350 time->d = 0; in do_adjust_special_early()
351 time->m++; in do_adjust_special_early()
354 timelib_do_normalize(time); in do_adjust_special_early()
441 timelib_sll timelib_epoch_days_from_time(timelib_time *time) in timelib_epoch_days_from_time() argument
443 timelib_sll y = time->y; // Make copy, as we don't want to change the original one in timelib_epoch_days_from_time()
446 y -= time->m <= 2; in timelib_epoch_days_from_time()
449 …day_of_year = (153 * (time->m + (time->m > 2 ? -3 : 9)) + 2)/5 + time->d - 1; // [… in timelib_epoch_days_from_time()
455 void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi) in timelib_update_ts() argument
457 do_adjust_special_early(time); in timelib_update_ts()
458 do_adjust_relative(time); in timelib_update_ts()
459 do_adjust_special(time); in timelib_update_ts()
461 time->sse = in timelib_update_ts()
462 (timelib_epoch_days_from_time(time) * SECS_PER_DAY) + in timelib_update_ts()
463 timelib_hms_to_seconds(time->h, time->i, time->s); in timelib_update_ts()
466 do_adjust_timezone(time, tzi); in timelib_update_ts()
468 time->sse_uptodate = 1; in timelib_update_ts()
469time->have_relative = time->relative.have_weekday_relative = time->relative.have_special_relative … in timelib_update_ts()
476 timelib_time time;
478 time = timelib_strtotime("10 Feb 2005 06:07:03 PM CET"); /* 1108055223 */
480 time.y, time.m, time.d, time.h, time.i, time.s, time.f, time.z, time.dst);
481 if (time.have_relative) {
483time.relative.y, time.relative.m, time.relative.d, time.relative.h, time.relative.i, time.relative…
485 if (time.have_weekday_relative) {
486 printf (" / %d", time.relative.weekday);
488 res = time2unixtime(&time);