@@ -44,6 +44,7 @@ time_t cvt_time(char const * time);
44
44
**************************************************************************************/
45
45
46
46
static time_t const EPOCH_AT_COMPILE_TIME = cvt_time(__DATE__);
47
+ static time_t const EPOCH = 0 ;
47
48
48
49
/* *************************************************************************************
49
50
* CTOR/DTOR
@@ -54,6 +55,9 @@ TimeService::TimeService()
54
55
#if defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_ARCH_MBED)
55
56
, _is_rtc_configured(false )
56
57
#endif
58
+ , _is_tz_configured(false )
59
+ , _timezone_offset(0 )
60
+ , _timezone_dst_until(0 )
57
61
{
58
62
59
63
}
@@ -100,12 +104,18 @@ void TimeService::setTimeZoneData(long offset, unsigned long dst_until)
100
104
if (_timezone_dst_until != dst_until)
101
105
DEBUG_DEBUG (" ArduinoIoTCloudTCP::%s tz_dst_unitl: [%ul]" , __FUNCTION__, dst_until);
102
106
_timezone_dst_until = dst_until;
107
+
108
+ _is_tz_configured = true ;
103
109
}
104
110
105
111
unsigned long TimeService::getLocalTime ()
106
112
{
107
113
unsigned long utc = getTime ();
108
- return utc + _timezone_offset;
114
+ if (_is_tz_configured) {
115
+ return utc + _timezone_offset;
116
+ } else {
117
+ return EPOCH;
118
+ }
109
119
}
110
120
111
121
unsigned long TimeService::getTimeFromString (const String& input)
0 commit comments