@@ -19,7 +19,7 @@ RTC_DATA_ATTR time_t lastGetLocationTS = 0; // can use this to throttle
19
19
RTC_DATA_ATTR location currentLocation = {
20
20
DEFAULT_LOCATION_LATITUDE, // lat
21
21
DEFAULT_LOCATION_LONGDITUDE, // lon
22
- " AEST-10AEDT,M10.1.0,M4.1.0/3 " , // timezone
22
+ DEFAULT_TIMEZONE , // timezone
23
23
" Melbourne" // default location is in Melbourne
24
24
};
25
25
@@ -757,7 +757,7 @@ uint32_t fnvHash(const char *str) {
757
757
// hashed values. It assumes that the "olson" string is a valid timezone name
758
758
// from the same version of the tzdb as it was compiled for. If passed an
759
759
// invalid string the behaviour is undefined.
760
- const char *getPosixTZforOlson (const char *olson, char *buf, size_t buflen ) {
760
+ const char *getPosixTZforOlson (const char *olson) {
761
761
static_assert (NumZones > 0 , " zones should not be empty" );
762
762
auto olsonHash = fnvHash (olson) & mask;
763
763
auto i = &zones[0 ];
@@ -771,9 +771,9 @@ const char *getPosixTZforOlson(const char *olson, char *buf, size_t buflen) {
771
771
}
772
772
}
773
773
if (i->hash == olsonHash) {
774
- return strncpy (buf, posix[i->posix ], buflen) ;
774
+ return posix[i->posix ];
775
775
}
776
- return nullptr ;
776
+ return " UTC0 " ; // couldn't find it, use default
777
777
}
778
778
779
779
const location *getLocation () {
@@ -810,8 +810,9 @@ const location *getLocation() {
810
810
loc.lon = double (responseObject[" lon" ]);
811
811
strncpy (loc.city , responseObject[" city" ], sizeof (loc.city ));
812
812
813
- auto olsonTZ = (const char *)responseObject[" timezone" ];
814
- if (getPosixTZforOlson (olsonTZ, loc.timezone , sizeof (loc.timezone ))) {
813
+ const char * olsonTZ = static_cast <const char *>(responseObject[" timezone" ]);
814
+ loc.timezone = getPosixTZforOlson (olsonTZ);
815
+ if ( loc.timezone ) {
815
816
currentLocation = loc;
816
817
lastGetLocationTS = now ();
817
818
Watchy::err = Watchy::OK;
0 commit comments