lubridate
lubridate copied to clipboard
Feature request: OS agnostic specification of locale when formatting
When formatting a date, one has to use a platform specific locale, e.g.:
library(lubridate)
D <- ymd("2020-07-01")
# Windows
stamp("01-janvier-1900", orders = "%d-%B-%Y", locale = "French_France.1252")(D)
# Linux
stamp("01-janvier-1900", orders = "%d-%B-%Y", locale = "fr_FR.UTF-8")(D)
{readr} has this very nice feature where the locale can be specified independently of the OS:
readr::parse_date("01-janvier-1900", format = "%d-%B-%Y", locale = readr::locale("fr"))
Desired interface
A similar specification of the locale with a platform independent function would be very nice:
stamp("01-janvier-1900", orders = "%d-%B-%Y", locale = locale("fr"))(D)
clock takes the same approach as readr by providing OS independent locale specification when formatting and parsing:
library(clock)
x <- date_parse("2020-07-01")
date_format(x, format = "%d-%B-%Y", locale = clock_locale("fr"))
#> [1] "01-juillet-2020"
Created on 2021-05-25 by the reprex package (v1.0.0)