[nq,qw] Fix strftime formats for windows

The incorrectness was hidden by the non-literal strings.
This commit is contained in:
Bill Currie 2021-03-30 17:38:42 +09:00
parent dac9166339
commit e93cff124c
2 changed files with 22 additions and 5 deletions

View file

@ -1101,14 +1101,22 @@ draw_time (view_t *view)
utc = time (0);
local = localtime (&utc);
#if defined(_WIN32) || defined(_WIN64)
# define HOUR12 "%I"
# define HOUR24 "%H"
# define PM "%p"
#else
# define HOUR12 "%l"
# define HOUR24 "%k"
# define PM "%P"
#endif
if (hud_time->int_val == 1) { // Use international format
strftime (st, sizeof (st), "%k:%M", local);
strftime (st, sizeof (st), HOUR24":%M", local);
draw_string (view, 8, 0, st);
} else if (hud_time->int_val >= 2) { // US AM/PM display
strftime (st, sizeof (st), "%l:%M %P", local);
strftime (st, sizeof (st), HOUR12":%M "PM, local);
draw_string (view, 8, 0, st);
}
}
static void

View file

@ -1563,11 +1563,20 @@ draw_time (view_t *view)
utc = time (0);
local = localtime (&utc);
#if defined(_WIN32) || defined(_WIN64)
# define HOUR12 "%I"
# define HOUR24 "%H"
# define PM "%p"
#else
# define HOUR12 "%l"
# define HOUR24 "%k"
# define PM "%P"
#endif
if (hud_time->int_val == 1) { // Use international format
strftime (st, sizeof (st), "%k:%M", local);
strftime (st, sizeof (st), HOUR24":%M", local);
draw_string (view, 8, 0, st);
} else if (hud_time->int_val >= 2) { // US AM/PM display
strftime (st, sizeof (st), "%l:%M %P", local);
strftime (st, sizeof (st), HOUR12":%M "PM, local);
draw_string (view, 8, 0, st);
}
}