From d1fc512af47b51bfd18a1647b809eaeb09a83ed5 Mon Sep 17 00:00:00 2001 From: Kaya <95276965+kytpbs@users.noreply.github.com> Date: Fri, 23 Aug 2024 18:56:17 +0300 Subject: [PATCH 1/2] fix time validity check --- src/utility/time/TimeService.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utility/time/TimeService.cpp b/src/utility/time/TimeService.cpp index 5bf081de7..2184d6d27 100644 --- a/src/utility/time/TimeService.cpp +++ b/src/utility/time/TimeService.cpp @@ -320,7 +320,9 @@ unsigned long TimeServiceClass::getRemoteTime() bool TimeServiceClass::isTimeValid(unsigned long const time) { - return (time > EPOCH_AT_COMPILE_TIME); + // EPOCH_AT_COMPILE_TIME is in local time, + // so we need to subtract the maximum possible timezone offset to make sure we are less then utc time + return (time > (EPOCH_AT_COMPILE_TIME - (/*UTC+14*/ 14 * 60 * 60))); } bool TimeServiceClass::isTimeZoneOffsetValid(long const offset) From 14eff9161089dce4da293f637890c0e3fc7c1a33 Mon Sep 17 00:00:00 2001 From: Kaya <95276965+kytpbs@users.noreply.github.com> Date: Mon, 9 Sep 2024 18:19:51 +0300 Subject: [PATCH 2/2] Improve comment Co-authored-by: Mattia Pennasilico --- src/utility/time/TimeService.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utility/time/TimeService.cpp b/src/utility/time/TimeService.cpp index 2184d6d27..e6d3cd4d3 100644 --- a/src/utility/time/TimeService.cpp +++ b/src/utility/time/TimeService.cpp @@ -320,9 +320,10 @@ unsigned long TimeServiceClass::getRemoteTime() bool TimeServiceClass::isTimeValid(unsigned long const time) { - // EPOCH_AT_COMPILE_TIME is in local time, - // so we need to subtract the maximum possible timezone offset to make sure we are less then utc time - return (time > (EPOCH_AT_COMPILE_TIME - (/*UTC+14*/ 14 * 60 * 60))); + /* EPOCH_AT_COMPILE_TIME is in local time, so we need to subtract the maximum + * possible timezone offset UTC+14 to make sure we are less then UTC time + */ + return (time > (EPOCH_AT_COMPILE_TIME - (14 * 60 * 60))); } bool TimeServiceClass::isTimeZoneOffsetValid(long const offset)