plotex v0.2.1 Plotex.Cldr.DateTime.Formatter
Implements the compilation and execution of date, time and datetime formats.
Link to this section Summary
Link to this section Functions
Link to this function
format(date, format, locale \\ Cldr.get_locale(), options \\ [])
format( Calendar.date() | Calendar.time() | Calendar.datetime(), String.t(), Cldr.LanguageTag.t() | Cldr.Locale.locale_name(), Keyword.t() ) :: {:ok, String.t()} | {:error, {module(), String.t()}}
Returns the formatted and localised date, time or datetime
for a given Date
, Time
, DateTime
or struct with the
appropriate fields.
Arguments
date
is aDate
,Time
,DateTime
or other struct that contains the required date and time fields.format
is a valid format string, for exampleyy/MM/dd hh:MM
locale
is any valid locale name returned byCldr.known_locale_names/0
or aCldr.LanguageTag
struct. The default isCldr.get_locale/0
options
is a keyword list of options. The valid options are:
Options
:number_system
. The resulting formatted and localised date/time string will be transliterated into this number system. Number system is anything returned fromCldr.Number.System.number_systems_for/1
NOTE This function is called by Cldr.Date/to_string/2
, Cldr.Time.to_string/2
and Cldr.DateTime.to_string/2
which is the preferred API.
Examples
iex> Elixir.Plotex.Cldr.DateTime.Formatter.format %{year: 2017, month: 9, day: 3, hour: 10, minute: 23},
...> "yy/MM/dd hh:MM", "en"
{:ok, "17/09/03 10:09"}
Link to this function