mirror of
https://github.com/espressif/openthread.git
synced 2026-07-25 05:24:08 +00:00
[uptime] enhance UptimeToString() and add flags (#12841)
This commit enhances the `UptimeToString()` function by introducing `UptimeStringFlags` to allow customization of the output string. Specifically, it adds the following flags: - `kUptimeStringIncludeMsec`: Includes milliseconds in the string. - `kUptimeStringSkipHoursIfZero`: Omits the `<hh>:` part when hours and days are zero. The commit also adds a new `UptimeToString()` overload that returns an `UptimeString` (a `String` object), simplifying usage in logging and other areas. All existing call sites are updated to use the new flags and the new overload where appropriate.
This commit is contained in:
committed by
GitHub
parent
7aa9d92600
commit
f8af79817b
@@ -533,7 +533,7 @@ void otConvertDurationInSecondsToString(uint32_t aDuration, char *aBuffer, uint1
|
||||
StringWriter writer(aBuffer, aSize);
|
||||
UptimeMsec uptime = static_cast<UptimeMsec>(aDuration) * Time::kOneSecondInMsec;
|
||||
|
||||
UptimeToString(uptime, writer, /* aIncludeMsec */ false);
|
||||
UptimeToString(uptime, writer, /* aFlags */ 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user