widget: fix time12 when it's 12pm

fixes #552
This commit is contained in:
Vaxry 2024-11-11 15:58:11 +00:00
parent d8bd25b52d
commit eadcbc0aed

View file

@ -138,7 +138,7 @@ static std::string getTime12h() {
const auto HRS = hhmmss.hours().count(); const auto HRS = hhmmss.hours().count();
const auto MINS = hhmmss.minutes().count(); const auto MINS = hhmmss.minutes().count();
return (HRS % 12 < 10 ? "0" : "") + std::to_string(HRS % 12) + ":" + (MINS < 10 ? "0" : "") + std::to_string(MINS) + (HRS < 12 ? " AM" : " PM"); return (HRS == 12 ? "12" : (HRS % 12 < 10 ? "0" : "") + std::to_string(HRS % 12)) + ":" + (MINS < 10 ? "0" : "") + std::to_string(MINS) + (HRS < 12 ? " AM" : " PM");
} }
IWidget::SFormatResult IWidget::formatString(std::string in) { IWidget::SFormatResult IWidget::formatString(std::string in) {