fix: timezone issue
This commit is contained in:
parent
ad7a6028b3
commit
27cec1d8cc
10 changed files with 27 additions and 28 deletions
models
|
@ -34,22 +34,17 @@ relay_set_name(relay_t *relay, const char *name)
|
|||
}
|
||||
|
||||
int
|
||||
relay_is_active(relay_t *relay, time_t timestamp_now)
|
||||
relay_is_active(relay_t *relay, struct tm *time_struct)
|
||||
{
|
||||
schedule_t *schedule = relay->schedules[helper_get_weekday(timestamp_now)];
|
||||
schedule_t *schedule = relay->schedules[helper_get_weekday(time_struct)];
|
||||
if(schedule->length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// we don't need days. reduce to hours, minutes and seconds
|
||||
timestamp_now %= SECONDS_PER_DAY;
|
||||
// finally remove seconds
|
||||
timestamp_now /= SECONDS_PER_MINUTE;
|
||||
|
||||
for(uint16_t i = 0; i < schedule->length; ++i)
|
||||
{
|
||||
if(period_includes_time(schedule->periods[i], timestamp_now))
|
||||
if(period_includes_time(schedule->periods[i], time_struct))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue