Zero pad years < 1000 to four digits.

This commit is contained in:
Jared Boone 2015-12-02 13:23:29 -08:00
parent b8ee19f8e6
commit d8c59e2ce2
2 changed files with 2 additions and 2 deletions

View File

@ -158,7 +158,7 @@ static std::string format_latlon_normalized(const int32_t normalized) {
static std::string format_datetime( static std::string format_datetime(
const DateTime& datetime const DateTime& datetime
) { ) {
return ui::to_string_dec_uint(datetime.year, 4) + "/" + return ui::to_string_dec_uint(datetime.year, 4, '0') + "/" +
ui::to_string_dec_uint(datetime.month, 2, '0') + "/" + ui::to_string_dec_uint(datetime.month, 2, '0') + "/" +
ui::to_string_dec_uint(datetime.day, 2, '0') + " " + ui::to_string_dec_uint(datetime.day, 2, '0') + " " +
ui::to_string_dec_uint(datetime.hour, 2, '0') + ":" + ui::to_string_dec_uint(datetime.hour, 2, '0') + ":" +

View File

@ -50,7 +50,7 @@ ManchesterFormatted TPMSModel::on_packet(const TPMSPacketMessage& message) {
rtc::RTC datetime; rtc::RTC datetime;
rtcGetTime(&RTCD1, &datetime); rtcGetTime(&RTCD1, &datetime);
std::string timestamp = std::string timestamp =
ui::to_string_dec_uint(datetime.year(), 4) + ui::to_string_dec_uint(datetime.year(), 4, '0') +
ui::to_string_dec_uint(datetime.month(), 2, '0') + ui::to_string_dec_uint(datetime.month(), 2, '0') +
ui::to_string_dec_uint(datetime.day(), 2, '0') + ui::to_string_dec_uint(datetime.day(), 2, '0') +
ui::to_string_dec_uint(datetime.hour(), 2, '0') + ui::to_string_dec_uint(datetime.hour(), 2, '0') +