Lines Matching refs:time
160 static void do_adjust_for_weekday(timelib_time* time) in do_adjust_for_weekday() argument
164 current_dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_for_weekday()
165 if (time->relative.weekday_behavior == 2) in do_adjust_for_weekday()
168 if (current_dow == 0 && time->relative.weekday != 0) { in do_adjust_for_weekday()
169 time->relative.weekday -= 7; in do_adjust_for_weekday()
174 if (time->relative.weekday == 0 && current_dow != 0) { in do_adjust_for_weekday()
175 time->relative.weekday = 7; in do_adjust_for_weekday()
178 time->d -= current_dow; in do_adjust_for_weekday()
179 time->d += time->relative.weekday; in do_adjust_for_weekday()
182 difference = time->relative.weekday - current_dow; in do_adjust_for_weekday()
183 …if ((time->relative.d < 0 && difference < 0) || (time->relative.d >= 0 && difference <= -time->rel… in do_adjust_for_weekday()
186 if (time->relative.weekday >= 0) { in do_adjust_for_weekday()
187 time->d += difference; in do_adjust_for_weekday()
189 time->d -= (7 - (abs(time->relative.weekday) - current_dow)); in do_adjust_for_weekday()
191 time->relative.have_weekday_relative = 0; in do_adjust_for_weekday()
205 void timelib_do_normalize(timelib_time* time) in timelib_do_normalize() argument
207 if (time->f != TIMELIB_UNSET) do_range_limit_fraction(&time->f, &time->s); in timelib_do_normalize()
208 if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->s, &time->i); in timelib_do_normalize()
209 if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->i, &time->h); in timelib_do_normalize()
210 if (time->s != TIMELIB_UNSET) do_range_limit(0, 24, 24, &time->h, &time->d); in timelib_do_normalize()
211 do_range_limit(1, 13, 12, &time->m, &time->y); in timelib_do_normalize()
213 do {} while (do_range_limit_days(&time->y, &time->m, &time->d)); in timelib_do_normalize()
214 do_range_limit(1, 13, 12, &time->m, &time->y); in timelib_do_normalize()
217 static void do_adjust_relative(timelib_time* time) in do_adjust_relative() argument
219 if (time->relative.have_weekday_relative) { in do_adjust_relative()
220 do_adjust_for_weekday(time); in do_adjust_relative()
222 timelib_do_normalize(time); in do_adjust_relative()
224 if (time->have_relative) { in do_adjust_relative()
225 time->f += time->relative.f; in do_adjust_relative()
227 time->s += time->relative.s; in do_adjust_relative()
228 time->i += time->relative.i; in do_adjust_relative()
229 time->h += time->relative.h; in do_adjust_relative()
231 time->d += time->relative.d; in do_adjust_relative()
232 time->m += time->relative.m; in do_adjust_relative()
233 time->y += time->relative.y; in do_adjust_relative()
236 switch (time->relative.first_last_day_of) { in do_adjust_relative()
238 time->d = 1; in do_adjust_relative()
241 time->d = 0; in do_adjust_relative()
242 time->m++; in do_adjust_relative()
246 timelib_do_normalize(time); in do_adjust_relative()
249 static void do_adjust_special_weekday(timelib_time* time) in do_adjust_special_weekday() argument
253 count = time->relative.special.amount; in do_adjust_special_weekday()
254 dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_special_weekday()
257 time->d += (count / 5) * 7; in do_adjust_special_weekday()
266 time->d -= 2; in do_adjust_special_weekday()
268 time->d -= 1; in do_adjust_special_weekday()
273 time->d += 1; in do_adjust_special_weekday()
277 time->d += 2; in do_adjust_special_weekday()
285 time->d += 2; in do_adjust_special_weekday()
287 time->d += 1; in do_adjust_special_weekday()
290 time->d -= 1; in do_adjust_special_weekday()
292 time->d -= 2; in do_adjust_special_weekday()
296 time->d += rem; in do_adjust_special_weekday()
299 static void do_adjust_special(timelib_time* time) in do_adjust_special() argument
301 if (time->relative.have_special_relative) { in do_adjust_special()
302 switch (time->relative.special.type) { in do_adjust_special()
304 do_adjust_special_weekday(time); in do_adjust_special()
308 timelib_do_normalize(time); in do_adjust_special()
309 memset(&(time->relative.special), 0, sizeof(time->relative.special)); in do_adjust_special()
312 static void do_adjust_special_early(timelib_time* time) in do_adjust_special_early() argument
314 if (time->relative.have_special_relative) { in do_adjust_special_early()
315 switch (time->relative.special.type) { in do_adjust_special_early()
317 time->d = 1; in do_adjust_special_early()
318 time->m += time->relative.m; in do_adjust_special_early()
319 time->relative.m = 0; in do_adjust_special_early()
322 time->d = 1; in do_adjust_special_early()
323 time->m += time->relative.m + 1; in do_adjust_special_early()
324 time->relative.m = 0; in do_adjust_special_early()
328 switch (time->relative.first_last_day_of) { in do_adjust_special_early()
330 time->d = 1; in do_adjust_special_early()
333 time->d = 0; in do_adjust_special_early()
334 time->m++; in do_adjust_special_early()
337 timelib_do_normalize(time); in do_adjust_special_early()
464 void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi) in timelib_update_ts() argument
468 do_adjust_special_early(time); in timelib_update_ts()
469 do_adjust_relative(time); in timelib_update_ts()
470 do_adjust_special(time); in timelib_update_ts()
471 res += do_years(time->y); in timelib_update_ts()
472 res += do_months(time->m, time->y); in timelib_update_ts()
473 res += do_days(time->d); in timelib_update_ts()
474 res += do_time(time->h, time->i, time->s); in timelib_update_ts()
475 time->sse = res; in timelib_update_ts()
477 res += do_adjust_timezone(time, tzi); in timelib_update_ts()
478 time->sse = res; in timelib_update_ts()
480 time->sse_uptodate = 1; in timelib_update_ts()
481 …time->have_relative = time->relative.have_weekday_relative = time->relative.have_special_relative … in timelib_update_ts()
488 timelib_time time;
490 time = timelib_strtotime("10 Feb 2005 06:07:03 PM CET"); /* 1108055223 */
492 time.y, time.m, time.d, time.h, time.i, time.s, time.f, time.z, time.dst);
493 if (time.have_relative) {
495 …time.relative.y, time.relative.m, time.relative.d, time.relative.h, time.relative.i, time.relative…
497 if (time.have_weekday_relative) {
498 printf (" / %d", time.relative.weekday);
500 res = time2unixtime(&time);