From 4352937c6cbf32261e60415a2a608a7a271b0e27 Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Sun, 9 Jun 2024 18:50:35 +0200 Subject: [PATCH] Fix issue with negative time zone --- library.properties | 2 +- src/jbwoprhelpers.cpp | 4 ++-- src/jbwoprhelpers.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library.properties b/library.properties index 3a9bf0d..8b36fc6 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=JBWopr -version=1.0.4 +version=1.0.5 author=Jonny Bergdahl maintainer=Jonny Bergdahl sentence=Support library for the Unexpected Maker W.O.P.R. boards diff --git a/src/jbwoprhelpers.cpp b/src/jbwoprhelpers.cpp index c440062..b85e6ea 100644 --- a/src/jbwoprhelpers.cpp +++ b/src/jbwoprhelpers.cpp @@ -12,7 +12,7 @@ bool JBTimeHelper::_isInitialized = false; -uint32_t JBTimeHelper::getUtcOffsetInSeconds() { +int64_t JBTimeHelper::getUtcOffsetInSeconds() { HTTPClient client; JBLogger log("timehelper"); @@ -31,7 +31,7 @@ uint32_t JBTimeHelper::getUtcOffsetInSeconds() { char sign = offset[0]; int hours = std::stoi(offset.substr(1, 2)); int minutes = std::stoi(offset.substr(4, 2)); - float result = hours * 3600 + + minutes * 60.0; + int64_t result = hours * 3600 + + minutes * 60.0; if (sign == '-') { result = -result; } diff --git a/src/jbwoprhelpers.h b/src/jbwoprhelpers.h index 971062f..eb0cf0f 100644 --- a/src/jbwoprhelpers.h +++ b/src/jbwoprhelpers.h @@ -27,7 +27,7 @@ class JBTimeHelper { /// @brief Get UTC offset in seconds /// @details Uses https://ipapi.co/timezone/ to get the local UTC offset /// @return UTC offset in seconds - static uint32_t getUtcOffsetInSeconds(); + static int64_t getUtcOffsetInSeconds(); /// @brief Get local time /// @param info Pointer to tm struct