Lines Matching refs:time

148 static void do_adjust_for_weekday(timelib_time* time)  in do_adjust_for_weekday()  argument
152 current_dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_for_weekday()
153 if (time->relative.weekday_behavior == 2) in do_adjust_for_weekday()
156 if (current_dow == 0 && time->relative.weekday != 0) { in do_adjust_for_weekday()
157 time->relative.weekday = -6; in do_adjust_for_weekday()
162 if (time->relative.weekday == 0 && current_dow != 0) { in do_adjust_for_weekday()
163 time->relative.weekday = 7; in do_adjust_for_weekday()
166 time->d -= current_dow; in do_adjust_for_weekday()
167 time->d += time->relative.weekday; in do_adjust_for_weekday()
170 difference = time->relative.weekday - current_dow; in do_adjust_for_weekday()
171 …if ((time->relative.d < 0 && difference < 0) || (time->relative.d >= 0 && difference <= -time->rel… in do_adjust_for_weekday()
174 if (time->relative.weekday >= 0) { in do_adjust_for_weekday()
175 time->d += difference; in do_adjust_for_weekday()
177 time->d -= (7 - (abs(time->relative.weekday) - current_dow)); in do_adjust_for_weekday()
179 time->relative.have_weekday_relative = 0; in do_adjust_for_weekday()
193 void timelib_do_normalize(timelib_time* time) in timelib_do_normalize() argument
195 if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->s, &time->i); in timelib_do_normalize()
196 if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->i, &time->h); in timelib_do_normalize()
197 if (time->s != TIMELIB_UNSET) do_range_limit(0, 24, 24, &time->h, &time->d); in timelib_do_normalize()
198 do_range_limit(1, 13, 12, &time->m, &time->y); in timelib_do_normalize()
200 do {} while (do_range_limit_days(&time->y, &time->m, &time->d)); in timelib_do_normalize()
201 do_range_limit(1, 13, 12, &time->m, &time->y); in timelib_do_normalize()
204 static void do_adjust_relative(timelib_time* time) in do_adjust_relative() argument
206 if (time->relative.have_weekday_relative) { in do_adjust_relative()
207 do_adjust_for_weekday(time); in do_adjust_relative()
209 timelib_do_normalize(time); in do_adjust_relative()
211 if (time->have_relative) { in do_adjust_relative()
212 time->s += time->relative.s; in do_adjust_relative()
213 time->i += time->relative.i; in do_adjust_relative()
214 time->h += time->relative.h; in do_adjust_relative()
216 time->d += time->relative.d; in do_adjust_relative()
217 time->m += time->relative.m; in do_adjust_relative()
218 time->y += time->relative.y; in do_adjust_relative()
221 switch (time->relative.first_last_day_of) { in do_adjust_relative()
223 time->d = 1; in do_adjust_relative()
226 time->d = 0; in do_adjust_relative()
227 time->m++; in do_adjust_relative()
231 timelib_do_normalize(time); in do_adjust_relative()
234 static void do_adjust_special_weekday(timelib_time* time) in do_adjust_special_weekday() argument
238 count = time->relative.special.amount; in do_adjust_special_weekday()
239 dow = timelib_day_of_week(time->y, time->m, time->d); in do_adjust_special_weekday()
242 time->d += (count / 5) * 7; in do_adjust_special_weekday()
251 time->d -= 2; in do_adjust_special_weekday()
253 time->d -= 1; in do_adjust_special_weekday()
258 time->d += 1; in do_adjust_special_weekday()
262 time->d += 2; in do_adjust_special_weekday()
270 time->d += 2; in do_adjust_special_weekday()
272 time->d += 1; in do_adjust_special_weekday()
275 time->d -= 1; in do_adjust_special_weekday()
277 time->d -= 2; in do_adjust_special_weekday()
281 time->d += rem; in do_adjust_special_weekday()
284 static void do_adjust_special(timelib_time* time) in do_adjust_special() argument
286 if (time->relative.have_special_relative) { in do_adjust_special()
287 switch (time->relative.special.type) { in do_adjust_special()
289 do_adjust_special_weekday(time); in do_adjust_special()
293 timelib_do_normalize(time); in do_adjust_special()
294 memset(&(time->relative.special), 0, sizeof(time->relative.special)); in do_adjust_special()
297 static void do_adjust_special_early(timelib_time* time) in do_adjust_special_early() argument
299 if (time->relative.have_special_relative) { in do_adjust_special_early()
300 switch (time->relative.special.type) { in do_adjust_special_early()
302 time->d = 1; in do_adjust_special_early()
303 time->m += time->relative.m; in do_adjust_special_early()
304 time->relative.m = 0; in do_adjust_special_early()
307 time->d = 1; in do_adjust_special_early()
308 time->m += time->relative.m + 1; in do_adjust_special_early()
309 time->relative.m = 0; in do_adjust_special_early()
313 switch (time->relative.first_last_day_of) { in do_adjust_special_early()
315 time->d = 1; in do_adjust_special_early()
318 time->d = 0; in do_adjust_special_early()
319 time->m++; in do_adjust_special_early()
322 timelib_do_normalize(time); in do_adjust_special_early()
449 void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi) in timelib_update_ts() argument
453 do_adjust_special_early(time); in timelib_update_ts()
454 do_adjust_relative(time); in timelib_update_ts()
455 do_adjust_special(time); in timelib_update_ts()
456 res += do_years(time->y); in timelib_update_ts()
457 res += do_months(time->m, time->y); in timelib_update_ts()
458 res += do_days(time->d); in timelib_update_ts()
459 res += do_time(time->h, time->i, time->s); in timelib_update_ts()
460 time->sse = res; in timelib_update_ts()
462 res += do_adjust_timezone(time, tzi); in timelib_update_ts()
463 time->sse = res; in timelib_update_ts()
465 time->sse_uptodate = 1; in timelib_update_ts()
466time->have_relative = time->relative.have_weekday_relative = time->relative.have_special_relative … in timelib_update_ts()
473 timelib_time time;
475 time = timelib_strtotime("10 Feb 2005 06:07:03 PM CET"); /* 1108055223 */
477 time.y, time.m, time.d, time.h, time.i, time.s, time.f, time.z, time.dst);
478 if (time.have_relative) {
480time.relative.y, time.relative.m, time.relative.d, time.relative.h, time.relative.i, time.relative…
482 if (time.have_weekday_relative) {
483 printf (" / %d", time.relative.weekday);
485 res = time2unixtime(&time);