From 41bc66d0e7465ff8f3b59fcfd11079795608724b Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Mon, 15 Mar 2021 12:15:19 +0100 Subject: #997 Fix og_tm_hours_mask Tests for e68fefe were made after 00pm (12:00) so we did not cover <12:00 cases for immediate commands that are logged (scheduled for the exact moment they are processed and ignored the fact they are stale so they are executed right away) In addition, libdbi was complaining about the data type used to represent the hours, they were not being inserted properly. From syslog: failed to query database (og_dbi_schedule_create:3288) 1264: Out of range value for column 'horas' at row 1 Fix og_tm_hours_mask so <12:00 immediate schedule is handled correctly. Change return type to uint16_t, as the 'hours' column type is smallint(4) Fixes e68fefe ("#997 Set stale check flag when processing schedule/create") --- src/rest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rest.c b/src/rest.c index 81d2f54..04a715f 100644 --- a/src/rest.c +++ b/src/rest.c @@ -3497,9 +3497,9 @@ static uint32_t og_tm_months_mask(struct tm *tm) return 1 << tm->tm_mon; } -static uint32_t og_tm_hours_mask(struct tm *tm) +static uint16_t og_tm_hours_mask(struct tm *tm) { - return 1 << (tm->tm_hour - 12); + return tm->tm_hour >= 12 ? 1 << (tm->tm_hour - 12) : 1 << tm->tm_hour; } static uint32_t og_tm_ampm(struct tm *tm) -- cgit v1.2.3-18-g5258