Move the conversation from time_t to String into DevInfoParser

This commit is contained in:
Thomas Basler
2024-01-20 01:09:42 +01:00
parent dcc157261e
commit e66060e769
4 changed files with 14 additions and 12 deletions

View File

@@ -137,6 +137,14 @@ time_t DevInfoParser::getFwBuildDateTime() const
return timegm(&timeinfo);
}
String DevInfoParser::getFwBuildDateTimeStr() const
{
char timebuffer[32];
const time_t t = getFwBuildDateTime();
std::strftime(timebuffer, sizeof(timebuffer), "%Y-%m-%d %H:%M:%S", gmtime(&t));
return timebuffer;
}
uint16_t DevInfoParser::getFwBootloaderVersion() const
{
HOY_SEMAPHORE_TAKE();
@@ -254,4 +262,4 @@ time_t DevInfoParser::timegm(const struct tm* t)
result -= 3600;
/*@ -matchanyintegral @*/
return (result);
}
}

View File

@@ -21,6 +21,7 @@ public:
uint16_t getFwBuildVersion() const;
time_t getFwBuildDateTime() const;
String getFwBuildDateTimeStr() const;
uint16_t getFwBootloaderVersion() const;
uint32_t getHwPartNumber() const;
@@ -43,4 +44,4 @@ private:
uint8_t _payloadDevInfoSimple[DEV_INFO_SIZE] = {};
uint8_t _devInfoSimpleLength = 0;
};
};