Lines Matching refs:time

144 static void do_adjust_for_weekday(timelib_time* time)  in do_adjust_for_weekday()  argument
148 current_dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_for_weekday()
149 if (time->relative.weekday_behavior == 2) in do_adjust_for_weekday()
151 if (time->relative.weekday == 0) { in do_adjust_for_weekday()
152 time->relative.weekday = 7; in do_adjust_for_weekday()
154 time->d -= current_dow; in do_adjust_for_weekday()
155 time->d += time->relative.weekday; in do_adjust_for_weekday()
158 difference = time->relative.weekday - current_dow; in do_adjust_for_weekday()
159 …if ((time->relative.d < 0 && difference < 0) || (time->relative.d >= 0 && difference <= -time->rel… in do_adjust_for_weekday()
162 if (time->relative.weekday >= 0) { in do_adjust_for_weekday()
163 time->d += difference; in do_adjust_for_weekday()
165 time->d -= (7 - (abs(time->relative.weekday) - current_dow)); in do_adjust_for_weekday()
167 time->relative.have_weekday_relative = 0; in do_adjust_for_weekday()
181 void timelib_do_normalize(timelib_time* time) in timelib_do_normalize() argument
183 if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->s, &time->i); in timelib_do_normalize()
184 if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->i, &time->h); in timelib_do_normalize()
185 if (time->s != TIMELIB_UNSET) do_range_limit(0, 24, 24, &time->h, &time->d); in timelib_do_normalize()
186 do_range_limit(1, 13, 12, &time->m, &time->y); in timelib_do_normalize()
188 do {} while (do_range_limit_days(&time->y, &time->m, &time->d)); in timelib_do_normalize()
189 do_range_limit(1, 13, 12, &time->m, &time->y); in timelib_do_normalize()
192 static void do_adjust_relative(timelib_time* time) in do_adjust_relative() argument
194 if (time->relative.have_weekday_relative) { in do_adjust_relative()
195 do_adjust_for_weekday(time); in do_adjust_relative()
197 timelib_do_normalize(time); in do_adjust_relative()
199 if (time->have_relative) { in do_adjust_relative()
200 time->s += time->relative.s; in do_adjust_relative()
201 time->i += time->relative.i; in do_adjust_relative()
202 time->h += time->relative.h; in do_adjust_relative()
204 time->d += time->relative.d; in do_adjust_relative()
205 time->m += time->relative.m; in do_adjust_relative()
206 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()
219 timelib_do_normalize(time); in do_adjust_relative()
222 static void do_adjust_special_weekday(timelib_time* time) in do_adjust_special_weekday() argument
226 count = time->relative.special.amount; in do_adjust_special_weekday()
227 dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_special_weekday()
230 time->d += (count / 5) * 7; in do_adjust_special_weekday()
239 time->d -= 2; in do_adjust_special_weekday()
241 time->d -= 1; in do_adjust_special_weekday()
246 time->d += 1; in do_adjust_special_weekday()
250 time->d += 2; in do_adjust_special_weekday()
258 time->d += 2; in do_adjust_special_weekday()
260 time->d += 1; in do_adjust_special_weekday()
263 time->d -= 1; in do_adjust_special_weekday()
265 time->d -= 2; in do_adjust_special_weekday()
269 time->d += rem; in do_adjust_special_weekday()
272 static void do_adjust_special(timelib_time* time) in do_adjust_special() argument
274 if (time->relative.have_special_relative) { in do_adjust_special()
275 switch (time->relative.special.type) { in do_adjust_special()
277 do_adjust_special_weekday(time); in do_adjust_special()
281 timelib_do_normalize(time); in do_adjust_special()
282 memset(&(time->relative.special), 0, sizeof(time->relative.special)); in do_adjust_special()
285 static void do_adjust_special_early(timelib_time* time) in do_adjust_special_early() argument
287 if (time->relative.have_special_relative) { in do_adjust_special_early()
288 switch (time->relative.special.type) { in do_adjust_special_early()
290 time->d = 1; in do_adjust_special_early()
291 time->m += time->relative.m; in do_adjust_special_early()
292 time->relative.m = 0; in do_adjust_special_early()
295 time->d = 1; in do_adjust_special_early()
296 time->m += time->relative.m + 1; in do_adjust_special_early()
297 time->relative.m = 0; in do_adjust_special_early()
301 switch (time->relative.first_last_day_of) { in do_adjust_special_early()
303 time->d = 1; in do_adjust_special_early()
306 time->d = 0; in do_adjust_special_early()
307 time->m++; in do_adjust_special_early()
310 timelib_do_normalize(time); in do_adjust_special_early()
437 void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi) in timelib_update_ts() argument
441 do_adjust_special_early(time); in timelib_update_ts()
442 do_adjust_relative(time); in timelib_update_ts()
443 do_adjust_special(time); in timelib_update_ts()
444 res += do_years(time->y); in timelib_update_ts()
445 res += do_months(time->m, time->y); in timelib_update_ts()
446 res += do_days(time->d); in timelib_update_ts()
447 res += do_time(time->h, time->i, time->s); in timelib_update_ts()
448 time->sse = res; in timelib_update_ts()
450 res += do_adjust_timezone(time, tzi); in timelib_update_ts()
451 time->sse = res; in timelib_update_ts()
453 time->sse_uptodate = 1; in timelib_update_ts()
454time->have_relative = time->relative.have_weekday_relative = time->relative.have_special_relative … in timelib_update_ts()
461 timelib_time time;
463 time = timelib_strtotime("10 Feb 2005 06:07:03 PM CET"); /* 1108055223 */
465 time.y, time.m, time.d, time.h, time.i, time.s, time.f, time.z, time.dst);
466 if (time.have_relative) {
468time.relative.y, time.relative.m, time.relative.d, time.relative.h, time.relative.i, time.relative…
470 if (time.have_weekday_relative) {
471 printf (" / %d", time.relative.weekday);
473 res = time2unixtime(&time);