15 #include "wvdailyevent.h"
17 #include "wvtimeutils.h"
26 #define NUM_MINS_IN_DAY (24*60)
27 #define NUM_SECS_IN_DAY (60*NUM_MINS_IN_DAY)
33 prev = wvstime().tv_sec;
34 configure(_first_hour, _num_per_day, _skip_first);
45 time_t now = wvstime().tv_sec;
50 assert(prev > 100000);
51 assert(next > 100000);
55 si.msec_timeout = msecdiff(now, next);
71 bool timer_rang =
false;
85 num_per_day = _num_per_day;
89 if (num_per_day > NUM_SECS_IN_DAY)
90 num_per_day = NUM_SECS_IN_DAY;
92 time_t max = num_per_day ? NUM_SECS_IN_DAY/num_per_day : 6*60*60;
97 prev = wvstime().tv_sec;
98 not_until = prev + max;
104 first_hour = _first_hour;
105 skip_first = _skip_first;
109 if (_num_per_day > NUM_MINS_IN_DAY)
110 _num_per_day = NUM_MINS_IN_DAY;
124 time_t interval = NUM_SECS_IN_DAY/num_per_day;
125 time_t start = prev + interval;
128 struct tm *tm = localtime(&start);
129 if (tm->tm_hour < first_hour)
131 start = prev - NUM_SECS_IN_DAY + 1;
132 tm = localtime(&start);
134 tm->tm_hour = first_hour;
135 tm->tm_min = tm->tm_sec = 0;
140 time_t next = prev + interval;
141 if ((next - start)%interval != 0)
142 next = start + (next - start)/interval * interval;
145 assert(next > 100000);
147 while (skip_first && next < not_until)