Skip to content

Commit 4bbe087

Browse files
committed
Add check for valid time
1 parent 14736a1 commit 4bbe087

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/property/types/CloudSchedule.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,20 @@ class Schedule {
113113
bool isActive() {
114114

115115
unsigned int now = _schedule_time_service->getLocalTime();
116-
if(checkSchedulePeriod(now, frm, to)) {
117-
/* We are in the schedule range */
118116

119-
if(checkScheduleMask(now, msk)) {
117+
if(checkTimeValid(now)) {
118+
/* We have to wait RTC configuration and Timezone setting from the cloud */
119+
120+
if(checkSchedulePeriod(now, frm, to)) {
121+
/* We are in the schedule range */
122+
123+
if(checkScheduleMask(now, msk)) {
120124

121-
/* We can assume now that the schedule is always repeating with fixed delta */
122-
unsigned int delta = getScheduleDelta(msk);
123-
if ( ( (std::max(now , frm) - std::min(now , frm)) % delta ) <= len ) {
124-
return true;
125+
/* We can assume now that the schedule is always repeating with fixed delta */
126+
unsigned int delta = getScheduleDelta(msk);
127+
if ( ( (std::max(now , frm) - std::min(now , frm)) % delta ) <= len ) {
128+
return true;
129+
}
125130
}
126131
}
127132
}
@@ -292,6 +297,10 @@ class Schedule {
292297
return ptm->tm_mon;
293298
}
294299

300+
bool checkTimeValid(unsigned int now) {
301+
return (now != 0);
302+
}
303+
295304
bool checkSchedulePeriod(unsigned int now, unsigned int frm, unsigned int to) {
296305
/* Check if current time is inside the schedule period. If 'to' is equal to
297306
* 0 the schedule has no end.

0 commit comments

Comments
 (0)