Determine locale-aware date and date-time formats
Source:R/locale_datetime_formats.R
locale_datetime_formats.RdReturns an ordered set of strptime()-style format strings, used as the
default value of accepted_datetime_formats in stabilize_date(),
stabilize_dttm(), and their siblings. Character input is tried against
each format in turn, in order, until one of them parses every element (see
those functions for details).
Usage
locale_datetime_formats(locale_time = Sys.getlocale("LC_TIME"))Arguments
- locale_time
(
character(1))LC_TIMElocale, as returned bySys.getlocale("LC_TIME"). Used to guess whether the locale's conventional date order is month-first (as in the United States) or day-first (most other locales); this is a coarse heuristic based on the locale string, not a full locale-aware calendar implementation.
Value
A character() vector of strptime()-style format strings,
always starting with "%Y-%m-%dT%H:%M:%S", "%Y-%m-%d %H:%M:%S", and
"%Y-%m-%d" (in that order), followed by the locale's conventional
day/month order with "/" and then "-" separators (each listed with,
then without, a " %H:%M:%S" suffix).
See also
Other date functions:
specify_date(),
stabilize_date(),
stabilize_date_scalar(),
to_date(),
to_date_scalar()
Other datetime functions:
specify_dttm(),
stabilize_dttm(),
stabilize_dttm_scalar(),
to_dttm(),
to_dttm_scalar()
Examples
locale_datetime_formats("en_US.UTF-8")
#> [1] "%Y-%m-%dT%H:%M:%S" "%Y-%m-%d %H:%M:%S" "%Y-%m-%d"
#> [4] "%m/%d/%Y %H:%M:%S" "%m/%d/%Y" "%m-%d-%Y %H:%M:%S"
#> [7] "%m-%d-%Y"
locale_datetime_formats("en_GB.UTF-8")
#> [1] "%Y-%m-%dT%H:%M:%S" "%Y-%m-%d %H:%M:%S" "%Y-%m-%d"
#> [4] "%d/%m/%Y %H:%M:%S" "%d/%m/%Y" "%d-%m-%Y %H:%M:%S"
#> [7] "%d-%m-%Y"