Bonfire.Common.Localise.Cldr.DateTime.Formatter (Bonfire v1.0.1-social-alpha.16)
View SourceImplements the compilation and execution of date, time and datetime formats.
Summary
Functions
@spec format( Cldr.Calendar.any_date_time(), String.t(), Cldr.Locale.locale_reference(), 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
dateis aDate,Time,DateTimeor other struct that contains the required date and time fields.formatis a valid format string, for exampleyy/MM/dd hh:MMlocaleis any valid locale name returned byCldr.known_locale_names/0or aCldr.LanguageTag.t/0struct. The default isCldr.get_locale/0optionsis a keyword list of options.
Options
:number_system. The resulting formatted and localised date/time string will be transliterated into this number system. Number system is anything returned fromBonfire.Common.Localise.Cldr.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> Bonfire.Common.Localise.Cldr.DateTime.Formatter.format(~U[2017-09-03 10:23:00.0Z], "yy/MM/dd hh:MM", "en")
{:ok, "17/09/03 10:09"}