Fix lint errors

This commit is contained in:
Thomas Basler
2025-04-02 18:15:29 +02:00
parent d61259bc56
commit 51b676be2f
2 changed files with 8 additions and 4 deletions

View File

@@ -9,7 +9,8 @@
uint8_t Utils::getWeekDay()
{
time_t now = time(NULL);
struct tm tm = *localtime(&now);
struct tm tm;
localtime_r(&now, &tm);
return tm.tm_mday;
}

View File

@@ -36,7 +36,8 @@ bool SunPositionClass::isDayPeriod() const
}
time_t now = time(NULL);
struct tm tm = *localtime(&now);
struct tm tm;
localtime_r(&now, &tm);
const uint32_t minutesPastMidnight = tm.tm_hour * 60 + tm.tm_min;
return (minutesPastMidnight >= _sunriseMinutes) && (minutesPastMidnight < _sunsetMinutes);
}
@@ -54,7 +55,8 @@ void SunPositionClass::setDoRecalc(const bool doRecalc)
bool SunPositionClass::checkRecalcDayChanged() const
{
time_t now = time(NULL);
struct tm tm = *localtime(&now);
struct tm tm;
localtime_r(&now, &tm);
return _lastSunPositionCalculatedYMD != CALC_UNIQUE_ID(tm);
}
@@ -122,7 +124,8 @@ void SunPositionClass::updateSunData()
bool SunPositionClass::getSunTime(struct tm* info, const uint32_t offset) const
{
time_t now = time(NULL);
struct tm tm = *localtime(&now);
struct tm tm;
localtime_r(&now, &tm);
tm.tm_sec = 0;
tm.tm_min = offset;