Obtain a standard time format that works across locales
Source:R/standard_date_time.R
standard_time.RdThe standard_time() function can be invoked in the format argument of the
fdt() function to help generate a locale-specific formatting string of a
certain 'type' of formatted time. The type value is a keyword that
represents precision and verbosity; the available keywords are "short" (the
default), "medium", "long", and "full".
Usage
standard_time(type = c("short", "medium", "long", "full"))Examples
With an input datetime of "2018-07-04 22:05(America/Vancouver)", we can
format as a time in a standardized way with standard_time() providing the
correct formatting string. This function is invoked in the format argument
of fdt():
fdt(
input = "2018-07-04 22:05(America/Vancouver)",
format = standard_time(type = "full")
)The locale can be changed and we don't have to worry about the particulars of the formatting string (they are standardized across locales).
fdt(
input = "2018-07-04 22:05(America/Vancouver)",
format = standard_time(type = "full"),
locale = fdt_locales_lst$nl
)We can use different type values to control the output date string. The
default is "short".
fdt(
input = "2018-07-04 22:05(America/Vancouver)",
format = standard_time()
)After that, it's "medium":
fdt(
input = "2018-07-04 22:05(America/Vancouver)",
format = standard_time(type = "medium")
)Then, "long":
fdt(
input = "2018-07-04 22:05(America/Vancouver)",
format = standard_time(type = "long")
)And finally up to "full", which was demonstrated in the first example.