@@ -44,6 +44,7 @@ time_t cvt_time(char const * time);
4444 **************************************************************************************/
4545
4646static time_t const EPOCH_AT_COMPILE_TIME = cvt_time(__DATE__);
47+ static time_t const EPOCH = 0 ;
4748
4849/* *************************************************************************************
4950 * CTOR/DTOR
@@ -54,6 +55,9 @@ TimeService::TimeService()
5455#if defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_ARCH_MBED)
5556, _is_rtc_configured(false )
5657#endif
58+ , _is_tz_configured(false )
59+ , _timezone_offset(0 )
60+ , _timezone_dst_until(0 )
5761{
5862
5963}
@@ -100,12 +104,18 @@ void TimeService::setTimeZoneData(long offset, unsigned long dst_until)
100104 if (_timezone_dst_until != dst_until)
101105 DEBUG_DEBUG (" ArduinoIoTCloudTCP::%s tz_dst_unitl: [%ul]" , __FUNCTION__, dst_until);
102106 _timezone_dst_until = dst_until;
107+
108+ _is_tz_configured = true ;
103109}
104110
105111unsigned long TimeService::getLocalTime ()
106112{
107113 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+ }
109119}
110120
111121unsigned long TimeService::getTimeFromString (const String& input)
0 commit comments