1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 12:25:20 +03:00

Fix RTC local time formatting (timezone offset) when no valid d… (#8731)

Fix RTC local time formatting (timezone offset) when no valid date/time
This commit is contained in:
Michael Keller 2019-08-19 23:32:48 +12:00 committed by GitHub
commit cbe8749d69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View file

@ -1187,15 +1187,15 @@ static bool sendFieldDefinition(char mainFrameChar, char deltaFrameChar, const v
// Buf must be at least FORMATTED_DATE_TIME_BUFSIZE
STATIC_UNIT_TESTED char *blackboxGetStartDateTime(char *buf)
{
#ifdef USE_RTC_TIME
#ifdef USE_RTC_TIME
dateTime_t dt;
// rtcGetDateTime will fill dt with 0000-01-01T00:00:00
// when time is not known.
rtcGetDateTime(&dt);
dateTimeFormatLocal(buf, &dt);
#else
#else
buf = "0000-01-01T00:00:00.000";
#endif
#endif
return buf;
}

View file

@ -200,7 +200,8 @@ bool dateTimeFormatUTC(char *buf, dateTime_t *dt)
bool dateTimeFormatLocal(char *buf, dateTime_t *dt)
{
return dateTimeFormat(buf, dt, timeConfig()->tz_offsetMinutes, false);
const int16_t timezoneOffset = rtcIsDateTimeValid(dt) ? timeConfig()->tz_offsetMinutes : 0;
return dateTimeFormat(buf, dt, timezoneOffset, false);
}
bool dateTimeFormatLocalShort(char *buf, dateTime_t *dt)