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()
152 if (time->relative.weekday == 0) { in do_adjust_for_weekday()
153 time->relative.weekday = 7; in do_adjust_for_weekday()
155 time->d -= current_dow; in do_adjust_for_weekday()
156 time->d += time->relative.weekday; in do_adjust_for_weekday()
159 difference = time->relative.weekday - current_dow; in do_adjust_for_weekday()
160 …if ((time->relative.d < 0 && difference < 0) || (time->relative.d >= 0 && difference <= -time->rel… in do_adjust_for_weekday()
163 if (time->relative.weekday >= 0) { in do_adjust_for_weekday()
164 time->d += difference; in do_adjust_for_weekday()
166 time->d -= (7 - (abs(time->relative.weekday) - current_dow)); in do_adjust_for_weekday()
168 time->relative.have_weekday_relative = 0; in do_adjust_for_weekday()
182 void timelib_do_normalize(timelib_time* time) in timelib_do_normalize() argument
184 if (time->s != TIMELIB_UNSET) do {} while (do_range_limit(0, 60, 60, &time->s, &time->i)); in timelib_do_normalize()
185 if (time->s != TIMELIB_UNSET) do {} while (do_range_limit(0, 60, 60, &time->i, &time->h)); in timelib_do_normalize()
186 if (time->s != TIMELIB_UNSET) do {} while (do_range_limit(0, 24, 24, &time->h, &time->d)); in timelib_do_normalize()
187 do {} while (do_range_limit(1, 13, 12, &time->m, &time->y)); in timelib_do_normalize()
189 do {} while (do_range_limit_days(&time->y, &time->m, &time->d)); in timelib_do_normalize()
190 do {} while (do_range_limit(1, 13, 12, &time->m, &time->y)); in timelib_do_normalize()
193 static void do_adjust_relative(timelib_time* time) in do_adjust_relative() argument
195 if (time->relative.have_weekday_relative) { in do_adjust_relative()
196 do_adjust_for_weekday(time); in do_adjust_relative()
198 timelib_do_normalize(time); in do_adjust_relative()
200 if (time->have_relative) { in do_adjust_relative()
201 time->s += time->relative.s; in do_adjust_relative()
202 time->i += time->relative.i; in do_adjust_relative()
203 time->h += time->relative.h; in do_adjust_relative()
205 time->d += time->relative.d; in do_adjust_relative()
206 time->m += time->relative.m; in do_adjust_relative()
207 time->y += time->relative.y; in do_adjust_relative()
209 switch (time->relative.first_last_day_of) { in do_adjust_relative()
211 time->d = 1; in do_adjust_relative()
214 time->d = 0; in do_adjust_relative()
215 time->m++; in do_adjust_relative()
218 timelib_do_normalize(time); in do_adjust_relative()
221 static void do_adjust_special_weekday(timelib_time* time) in do_adjust_special_weekday() argument
225 count = time->relative.special.amount; in do_adjust_special_weekday()
227 current_dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_special_weekday()
231 time->d += 2; in do_adjust_special_weekday()
235 time->d += 1; in do_adjust_special_weekday()
240 time->d += 2; in do_adjust_special_weekday()
244 time->d += 1; in do_adjust_special_weekday()
247 time->d += (count / 5) * 7; in do_adjust_special_weekday()
249 current_dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_special_weekday()
250 time->d += (count % 5); in do_adjust_special_weekday()
252 time->d += 2; in do_adjust_special_weekday()
257 time->d -= 2; in do_adjust_special_weekday()
261 time->d -= 1; in do_adjust_special_weekday()
264 time->d += (count / 5) * 7; in do_adjust_special_weekday()
266 current_dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_special_weekday()
267 time->d += (count % 5); in do_adjust_special_weekday()
269 time->d -= 2; in do_adjust_special_weekday()
274 static void do_adjust_special(timelib_time* time) in do_adjust_special() argument
276 if (time->relative.have_special_relative) { in do_adjust_special()
277 switch (time->relative.special.type) { in do_adjust_special()
279 do_adjust_special_weekday(time); in do_adjust_special()
283 timelib_do_normalize(time); in do_adjust_special()
284 memset(&(time->relative.special), 0, sizeof(time->relative.special)); in do_adjust_special()
287 static void do_adjust_special_early(timelib_time* time) in do_adjust_special_early() argument
289 if (time->relative.have_special_relative) { in do_adjust_special_early()
290 switch (time->relative.special.type) { in do_adjust_special_early()
292 time->d = 1; in do_adjust_special_early()
293 time->m += time->relative.m; in do_adjust_special_early()
294 time->relative.m = 0; in do_adjust_special_early()
297 time->d = 1; in do_adjust_special_early()
298 time->m += time->relative.m + 1; in do_adjust_special_early()
299 time->relative.m = 0; in do_adjust_special_early()
303 timelib_do_normalize(time); in do_adjust_special_early()
430 void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi) in timelib_update_ts() argument
434 do_adjust_special_early(time); in timelib_update_ts()
435 do_adjust_relative(time); in timelib_update_ts()
436 do_adjust_special(time); in timelib_update_ts()
437 res += do_years(time->y); in timelib_update_ts()
438 res += do_months(time->m, time->y); in timelib_update_ts()
439 res += do_days(time->d); in timelib_update_ts()
440 res += do_time(time->h, time->i, time->s); in timelib_update_ts()
441 time->sse = res; in timelib_update_ts()
443 res += do_adjust_timezone(time, tzi); in timelib_update_ts()
444 time->sse = res; in timelib_update_ts()
446 time->sse_uptodate = 1; in timelib_update_ts()
447 …time->have_relative = time->relative.have_weekday_relative = time->relative.have_special_relative … in timelib_update_ts()
454 timelib_time time;
456 time = timelib_strtotime("10 Feb 2005 06:07:03 PM CET"); /* 1108055223 */
458 time.y, time.m, time.d, time.h, time.i, time.s, time.f, time.z, time.dst);
459 if (time.have_relative) {
461 …time.relative.y, time.relative.m, time.relative.d, time.relative.h, time.relative.i, time.relative…
463 if (time.have_weekday_relative) {
464 printf (" / %d", time.relative.weekday);
466 res = time2unixtime(&time);