Is there a way to format a POSIXct object in R and specifying the LC_TIME in that call?
Ie I have this code which returns the object in the German format
t <- Sys.time()
fmt <- "%a, %d %b %Y %H:%M:%S GMT"
format(t, fmt)
#> [1] "Mi, 23 Mrz 2022 14:57:50 GMT"
Sys.getlocale("LC_TIME")
#> [1] "German_Germany.1252"
The format I want can be achieved by setting the LC_TIME, but this is not what I want. Instead I want to find a solution without changing the options of my R session or my locale.
Sys.setlocale("LC_TIME", "C")
format(t, fmt)
#> [1] "Wed, 23 Mar 2022 14:57:50 GMT"
# correct output, but changing the locale :(
Ideally, I want something like format(t, fmt, LC_TIME = "C") or similar with minimal external dependencies and not changing anything else...