According to Locales section in Elisp manual, the format-time-string
function is influenced by the system locale configuration. Moreover, the function docstring says "%p is the locale’s equivalent of either AM or PM.".
Because of these tips, I wrote the following code to changed the locale temporarily before using the format function:
(let ((system-time-locale "en_US.UTF-8"))
(format-time-string "%r %p" (current-time)))
After some tries at the scratch buffer, it seems that using the "en_US.UTF-8" locale prints the "PM"/"AM". These are the results after executing each sexp with C-j (eval-print-last-sexp
):
(let ((system-time-locale "en_US.UTF-8"))
(format-time-string "%r %p" (current-time)))
"01:21:33 PM PM"
(let ((system-time-locale "en_DK.UTF-8"))
(format-time-string "%r %p" (current-time)))
"01:21:55 "
(let ((system-time-locale "en_UK.UTF-8"))
(format-time-string "%r %p" (current-time)))
"01:22:14 "