From 6248ac1c166b22f4de82680c5ceb26377d1d4e72 Mon Sep 17 00:00:00 2001 From: Ervin Hegedus Date: Sat, 7 Jun 2025 11:53:38 +0200 Subject: [PATCH 1/2] fix: change the format of the ascTime() function --- src/utils/string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/string.h b/src/utils/string.h index ca2967aa5f..8b97beebb3 100644 --- a/src/utils/string.h +++ b/src/utils/string.h @@ -74,7 +74,7 @@ inline std::string ascTime(const time_t *t) { struct tm timeinfo; localtime_r(t, &timeinfo); char tstr[std::size("Www Mmm dd hh:mm:ss yyyy")]; - strftime(tstr, std::size(tstr), "%c", &timeinfo); + strftime(tstr, std::size(tstr), "%a %b %d %H:%M:%S %Y", &timeinfo); return tstr; } From 169e719e7a639482ef96c21622debda84f81bc9e Mon Sep 17 00:00:00 2001 From: Ervin Hegedus Date: Sat, 7 Jun 2025 20:51:25 +0200 Subject: [PATCH 2/2] Replace format to `%T` Co-authored-by: Max Leske <250711+theseion@users.noreply.github.com> --- src/utils/string.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/string.h b/src/utils/string.h index 8b97beebb3..7ef5d04892 100644 --- a/src/utils/string.h +++ b/src/utils/string.h @@ -74,7 +74,11 @@ inline std::string ascTime(const time_t *t) { struct tm timeinfo; localtime_r(t, &timeinfo); char tstr[std::size("Www Mmm dd hh:mm:ss yyyy")]; - strftime(tstr, std::size(tstr), "%a %b %d %H:%M:%S %Y", &timeinfo); + // `%c` is equivalent to `%a %b %e %T %Y` with a fixed length, even though zero-padded + // month of day is optional, depending on the locale. This would lead to an empty space, e.g., + // `Sat Jun 7 11:46:23 2025` (notice the two spaces before the day of month). + // Use `%d` instead and enforce padding. + strftime(tstr, std::size(tstr), "%a %b %d %T %Y", &timeinfo); return tstr; }