29 memset (tb->
clib_time, 0, sizeof (*clib_time));
106 u32 year, month, hours, minutes, seconds, nanoseconds;
107 u32 days_in_year, days_in_month, day_of_month;
108 u32 days_since_epoch;
114 days_since_epoch = 0;
119 days_since_epoch += days_in_year;
120 now = now - ((
f64) days_in_year) * 86400.0;
125 days_since_epoch -= days_in_year;
126 now += ((
f64) days_in_year) * 86400;
137 days_since_epoch += days_in_month;
138 now = now - ((
f64) days_in_month) * 86400.0;
143 days_since_epoch -= days_in_month;
144 now += ((
f64) days_in_month) * 86400;
160 day_name_index = days_since_epoch % 7;
162 hours = (
u32) (now / (3600.0));
163 now -= (
f64) (hours * 3600);
165 minutes = (
u32) (now / 60.0);
166 now -= (
f64) (minutes * 60);
168 seconds = (
u32) (now);
169 now -= (
f64) (seconds);
171 nanoseconds = (
f64) (now * 1e9);
175 cp->
day = day_of_month;
188 u32 year, days_in_year, month, days_in_month;
192 while (year < cp->year)
195 now += ((
f64) days_in_year) * 86400.0;
201 while (month < cp->month)
207 now += ((
f64) days_in_month) * 86400.0;
211 now += ((
f64) cp->
day - 1) * 86400.0;
212 now += ((
f64) cp->
hour) * 3600.0;
235 start_time -= 86400.0;
253 return ((
f64)
i) * 86400.0;
262 f64 now = va_arg (*args,
f64);
267 s =
format (s,
"%s, %u %s %u %u:%02u:%02u",
280 u32 start_hour, start_minute, start_second;
281 u32 end_hour, end_minute, end_second;
283 start_hour = start_minute = start_second
284 = end_hour = end_minute = end_second = 0;
286 if (
unformat (input,
"%u:%u:%u - %u:%u:%u",
287 &start_hour, &start_minute, &start_second,
288 &end_hour, &end_minute, &end_second))
290 else if (
unformat (input,
"%u:%u - %u:%u",
291 &start_hour, &start_minute, &end_hour, &end_minute))
293 else if (
unformat (input,
"%u - %u", &start_hour, &end_hour))
300 cp->
hour = start_hour;
301 cp->
minute = start_minute;
302 cp->
second = start_second;
321 int day_range_match = 0;
322 int time_range_match = 0;
323 f64 range_start_time_offset;
324 f64 range_end_time_offset;
326 u8 *start_day = 0, *end_day = 0;
333 &&
unformat (input,
"%s - %s", &start_day, &end_day))
335 range_start_time_offset
341 time_range_match = 0;
343 else if (!day_range_match &&
unformat (input,
"%s", &start_day))
345 range_start_time_offset
347 range_end_time_offset = range_start_time_offset + 86399.0;
351 time_range_match = 0;
353 else if (day_range_match &&
357 for (now = range_start_time_offset; now <= range_end_time_offset;
362 new_rp->
end = now + tmp->
end;
365 time_range_match = 1;
367 else if (time_range_match)
377 if (time_range_match)
394 f64 second_sunday_march_2am;
395 f64 first_sunday_november_2am;
437 second_sunday_march_2am += 86400.0;
445 second_sunday_march_2am += 86400.0;
449 second_sunday_march_2am -= 86400.0;
462 first_sunday_november_2am += 86400.0;
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
uword unformat_clib_timebase_range_vector(unformat_input_t *input, va_list *args)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
clib_timebase_daylight_time_t
f64 clib_timebase_offset_from_sunday(u8 *day)
f64 clib_timebase_components_to_time(clib_timebase_component_t *cp)
void clib_timebase_time_to_components(f64 now, clib_timebase_component_t *cp)
clib_timebase_daylight_time_t daylight_time_type
static const char * day_names_calendar_order[]
u8 * format_clib_timebase_time(u8 *s, va_list *args)
void clib_time_init(clib_time_t *c)
static const char * month_short_names[]
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
f64 clib_timebase_find_sunday_midnight(f64 start_time)
uword unformat_clib_timebase_range_hms(unformat_input_t *input, va_list *args)
void clib_timebase_init(clib_timebase_t *tb, i32 timezone_offset_in_hours, clib_timebase_daylight_time_t daylight_type, clib_time_t *clib_time)
static int clib_timebase_is_leap_year(u32 year)
static const char * day_names_epoch_order[]
static const u32 days_per_month[]
static void * clib_mem_alloc_aligned(uword size, uword align)
f64 clib_timebase_summer_offset(clib_timebase_t *tb, f64 now)
#define CLIB_CACHE_LINE_BYTES