Skip to content

Commit 169e719

Browse files
airweentheseion
andauthored
Replace format to %T
Co-authored-by: Max Leske <250711+theseion@users.noreply.github.com>
1 parent 6248ac1 commit 169e719

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/utils/string.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ inline std::string ascTime(const time_t *t) {
7474
struct tm timeinfo;
7575
localtime_r(t, &timeinfo);
7676
char tstr[std::size("Www Mmm dd hh:mm:ss yyyy")];
77-
strftime(tstr, std::size(tstr), "%a %b %d %H:%M:%S %Y", &timeinfo);
77+
// `%c` is equivalent to `%a %b %e %T %Y` with a fixed length, even though zero-padded
78+
// month of day is optional, depending on the locale. This would lead to an empty space, e.g.,
79+
// `Sat Jun 7 11:46:23 2025` (notice the two spaces before the day of month).
80+
// Use `%d` instead and enforce padding.
81+
strftime(tstr, std::size(tstr), "%a %b %d %T %Y", &timeinfo);
7882
return tstr;
7983
}
8084

0 commit comments

Comments
 (0)