lubridate
lubridate copied to clipboard
French labels for months and weekdays are incorrect
I'm getting some new, unexpected behaviour with lubridate
and French labels for months and weekdays.
My scripts previously worked to output properly formatted labels, but on a new laptop and updated lubridate
, getting some weird labels.
Session Info:
R version 4.2.3 (2023-03-15 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)
locale:
[1] LC_COLLATE=English_Canada.utf8 LC_CTYPE=English_Canada.utf8 LC_MONETARY=English_Canada.utf8
[4] LC_NUMERIC=C LC_TIME=French_France.1252
other attached packages:
[1] lubridate_1.9.2
Example script:
Sys.setlocale("LC_TIME", "French")
library(lubridate)
dt <- seq(ymd("2018-01-01"), ymd("2018-12-31"), "month")
day <- seq(ymd("2018-01-01"), ymd("2018-01-08"), "day")
month(dt, label = TRUE, abbr = FALSE)
month(dt, label = TRUE, abbr = TRUE)
wday(day, label = TRUE, abbr = TRUE)
Output:
Please note - extra characters for months february (f<e9>vrier
), december (d<e9>cembre
), august (ao<fb>t
)
and extra slashes in all weekdays, e.g., lun\\.
month(dt, label = TRUE, abbr = FALSE)
[1] janvier f<e9>vrier mars avril mai juin juillet ao<fb>t septembre
[10] octobre novembre d<e9>cembre
12 Levels: janvier < f<e9>vrier < mars < avril < mai < juin < juillet < ao<fb>t < septembre < octobre < ... < d<e9>cembre
> month(dt, label = TRUE, abbr = TRUE)
[1] janv f<e9>vr mars avr mai juin juil ao<fb>t sept oct nov d<e9>c
Levels: janv < f<e9>vr < mars < avr < mai < juin < juil < ao<fb>t < sept < oct < nov < d<e9>c
> wday(day, label = TRUE, abbr = TRUE)
[1] lun\\. mar\\. mer\\. jeu\\. ven\\. sam\\. dim\\. lun\\.
Levels: dim\\. < lun\\. < mar\\. < mer\\. < jeu\\. < ven\\. < sam\\.
I was able to fix the months by specifying utf8 in the locale option:
month(dt, label = TRUE, abbr = FALSE, locale = "fr_CA.utf8")
[1] janvier février mars avril mai juin juillet août septembre
[10] octobre novembre décembre
12 Levels: janvier < février < mars < avril < mai < juin < juillet < août < ... < décembre
but the week output still has the extra slashes.