Returns a string represenation of a date, with month names in the chosen locale and leading zeros removed. Month and date formats are customisable without having to remember format codes. Defaults are geared towards Czech-locale dates.

format_date_human(
  date = lubridate::now(),
  month_format = c("long", "short", "number"),
  year_format = c("long", "short"),
  locale = "cs_CZ.UTF-8",
  day_dot = TRUE
)

Arguments

date

a date, object of class POSIXct. Defaults to lubridate::now()

month_format

Month format. `"long"` for full month name (the default), `"short"` for month abbreviation, or `"number"` for numeric.

year_format

`"long"` for 4-digit (default), `"short"` for 2-digit.

locale

Locale string. Defaults to `"cs_CZ.UTF-8"`

day_dot

Whether to put a dot after the day. Defaults to TRUE.

Value

a string of same length as input

Examples

format_date_human()
#> Warning: OS reports request to set locale to "cs_CZ.UTF-8" cannot be honored
#> 22. August 2024
format_date_human(month_format = "short")
#> Warning: OS reports request to set locale to "cs_CZ.UTF-8" cannot be honored
#> 22. Aug 2024
format_date_human(month_format = "number")
#> Warning: OS reports request to set locale to "cs_CZ.UTF-8" cannot be honored
#> 22. 8. 2024
format_date_human(year_format = "long")
#> Warning: OS reports request to set locale to "cs_CZ.UTF-8" cannot be honored
#> 22. August 2024
format_date_human(month_format = "short", locale = "fr_FR")
#> Warning: OS reports request to set locale to "fr_FR" cannot be honored
#> 22. Aug 2024
format_date_human(month_format = "short", locale = "en_US", day_dot = FALSE)
#> Warning: OS reports request to set locale to "en_US" cannot be honored
#> 22 Aug 2024
format_date_human(date = c(lubridate::now(),
                           lubridate::now() - 100000),
                  month_format = "short", locale = "fr_FR", day_dot = FALSE)
#> Warning: OS reports request to set locale to "fr_FR" cannot be honored
#> 22 Aug 2024
#> 21 Aug 2024