View Source Cldr.Strftime (Cldr Strftime Options generator for Calendar.strftime/3 v1.0.1)

Summary

Functions

Returns a keyword list of options than can be applied to NimbleStrftime.format/3.

Functions

Link to this function

preferred_formats(locale, format, strftime_backend)

View Source
Link to this function

strftime_options!(locale \\ Cldr.get_locale(), options \\ [])

View Source

Returns a keyword list of options than can be applied to NimbleStrftime.format/3.

The hex package nimble_strftime provides a format/3 function to format dates, times and datetimes. It takes a set of options that can return day, month and am/pm names.

strftime_options! returns a keyword list than can be used as these options to return localised names for days, months and am/pm.

Arguments

Options

  • :format determines the format of the date, time or date time. The options are :short, :medium, :long and :full. The default is :medium.

Example

=> Cldr.Strftime.strftime_options!
[
  am_pm_names: #Function<0.117825700/1 in MyApp.Cldr.Calendar.strftime_options!/2>,
  month_names: #Function<1.117825700/1 in MyApp.Cldr.Calendar.strftime_options!/2>,
  abbreviated_month_names: #Function<2.117825700/1 in MyApp.Cldr.Calendar.strftime_options!/2>,
  day_of_week_names: #Function<3.117825700/1 in MyApp.Cldr.Calendar.strftime_options!/2>,
  abbreviated_day_of_week_names: #Function<4.117825700/1 in MyApp.Cldr.Calendar.strftime_options!/2>,
  preferred_date: "%b %d, %Y",
  preferred_time: "%H:%M:%S %p",
  preferred_datetime: "%b %d, %Y, %H:%M:%S %p"
]

Typical usage from Elixir 1.11

iex> Calendar.strftime ~U[2019-08-26 13:52:06.0Z], "%x", Cldr.Strftime.strftime_options!
"Aug 26, 2019"

iex> Calendar.strftime ~U[2019-08-26 13:52:06.0Z], "%X", Cldr.Strftime.strftime_options!
"13:52:06 PM"

iex> Calendar.strftime ~U[2019-08-26 13:52:06.0Z], "%c", Cldr.Strftime.strftime_options!
"Aug 26, 2019, 13:52:06 PM"