From ee2e68f44f7b9ee099f98b668257b5d57a86a695 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 10 Aug 2021 18:14:30 +0100 Subject: Enable numeric conversion warning and fix the fallout --- lib/dbTypes.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/dbTypes.h') diff --git a/lib/dbTypes.h b/lib/dbTypes.h index f49c929..e17315b 100644 --- a/lib/dbTypes.h +++ b/lib/dbTypes.h @@ -46,7 +46,11 @@ namespace MyGrate { struct Date { inline Date() { } inline Date(uint16_t y, uint8_t m, uint8_t d) : year {y}, month {m}, day {d} { } - explicit inline Date(const tm & tm) : Date(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday) { } + explicit inline Date(const tm & tm) : + Date(boost::numeric_cast(tm.tm_year + 1900), boost::numeric_cast(tm.tm_mon + 1), + boost::numeric_cast(tm.tm_mday)) + { + } uint16_t year; uint8_t month; uint8_t day; @@ -54,7 +58,11 @@ namespace MyGrate { struct Time { inline Time() { } inline Time(uint8_t h, uint8_t m, uint8_t s) : hour {h}, minute {m}, second {s} { } - explicit inline Time(const tm & tm) : Time(tm.tm_hour, tm.tm_min, tm.tm_sec) { } + explicit inline Time(const tm & tm) : + Time(boost::numeric_cast(tm.tm_hour), boost::numeric_cast(tm.tm_min), + boost::numeric_cast(tm.tm_sec)) + { + } uint8_t hour; uint8_t minute; uint8_t second; -- cgit v1.2.3