summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2021-03-15 12:15:19 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-03-15 12:17:56 +0100
commit41bc66d0e7465ff8f3b59fcfd11079795608724b (patch)
tree8d681558fdbcdafdf9937cb11f6852b948bca2da
parent8b7b5f33a126e3884ec540d79256a4cd704a4887 (diff)
#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")
-rw-r--r--src/rest.c4
1 files 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)