Cldr Dates & Times v1.2.0 Cldr.DateTime.Format View Source
Manages the Date, TIme and DateTime formats defined by CLDR.
The functions in Cldr.DateTime.Format
are
primarily concerned with encapsulating the
data from CLDR in functions that are used
during the formatting process.
Link to this section Summary
Functions
Returns a list of calendars defined for a given locale
Returns a list of the date_time format types that are available in all locales
Returns a map of the standard date formats for a given locale and calendar
Returns a map of the available non-standard datetime formats for a given locale and calendar
Returns a map of the standard datetime formats for a given locale and calendar
Returns a list of all formats defined for the configured locales
Returns the GMT offset format list for a for a timezone offset for a given locale
Returns the GMT format string for a for a timezone with an offset of zero for a given locale
Returns the postive and negative hour format for a timezone offset for a given locale
Returns a map of the standard time formats for a given locale and calendar
Link to this section Types
Link to this section Functions
calendars_for(Cldr.Locale.name() | Cldr.LanguageTag.t()) :: [calendar(), ...]
Returns a list of calendars defined for a given locale.
Options
locale
is any valid locale name returned byCldr.known_locale_names/0
or aCldr.LanguageTag
struct. The default isCldr.get_current_locale/0
Example
iex> Cldr.DateTime.Format.calendars_for "en"
{:ok, [:buddhist, :chinese, :coptic, :dangi, :ethiopic, :ethiopic_amete_alem,
:generic, :gregorian, :hebrew, :indian, :islamic, :islamic_civil,
:islamic_rgsa, :islamic_tbla, :islamic_umalqura, :japanese, :persian, :roc]}
Returns a list of the date_time format types that are available in all locales.
The format types returned by common_date_time_format_names
are guaranteed to be available in all known locales,
Example:
iex> Cldr.DateTime.Format.common_date_time_format_names
[:bh, :bhm, :bhms, :d, :e, :e_bhm, :e_bhms, :e_hm, :e_hms, :ed, :ehm,
:ehms, :gy, :gy_mm_md, :gy_mmm, :gy_mmm_ed, :h, :hm, :hms, :hmsv,
:hmv, :m, :m_ed, :md, :mm_md, :mmm, :mmm_ed, :mmm_md,
:mmmmw_count_other, :ms, :y, :y_m, :y_m_ed, :y_md, :y_mm_md, :y_mmm,
:y_mmm_ed, :y_mmmm, :y_qqq, :y_qqqq, :yw_count_other]
date_formats(Cldr.Locale.name() | Cldr.LanguageTag.t(), calendar()) :: standard_formats()
Returns a map of the standard date formats for a given locale and calendar.
locale
is any locale returned byCldr.known_locale_names/0
calendar
is any calendar returned byCldr.DateTime.Format.calendars_for/1
The default is:gregorian
Examples:
iex> Cldr.DateTime.Format.date_formats "en"
{:ok, %Cldr.Date.Formats{
full: "EEEE, MMMM d, y",
long: "MMMM d, y",
medium: "MMM d, y",
short: "M/d/yy"
}}
iex> Cldr.DateTime.Format.date_formats "en", :buddhist
{:ok, %Cldr.Date.Formats{
full: "EEEE, MMMM d, y G",
long: "MMMM d, y G",
medium: "MMM d, y G",
short: "M/d/y GGGGG"
}}
date_time_available_formats(Cldr.Locale.name() | Cldr.LanguageTag, calendar()) :: formats()
Returns a map of the available non-standard datetime formats for a given locale and calendar.
locale
is any locale returned byCldr.known_locale_names/0
calendar
is any calendar returned byCldr.DateTime.Format.calendars_for/1
The default is:gregorian
Examples:
iex> Cldr.DateTime.Format.date_time_available_formats "en"
{:ok, %{
mm_md: "MMM d",
mmm: "LLL",
hmv: "h:mm a v",
gy_mm_md: "MMM d, y G",
ehm: "E h:mm a",
hms: "h:mm:ss a",
y_m: "M/y",
gy_mmm: "MMM y G",
mmm_md: "MMMM d",
gy: "y G",
e_bhm: "E h:mm B",
e_bhms: "E h:mm:ss B",
y_mmmm: "MMMM y",
ehms: "E h:mm:ss a",
hm: "h:mm a",
yw_count_other: "'week' w 'of' Y",
bhm: "h:mm B",
e: "ccc",
bhms: "h:mm:ss B",
y_mm_md: "MMM d, y",
y_md: "M/d/y",
e_hm: "E HH:mm",
h: "h a",
y: "y",
y_m_ed: "E, M/d/y",
mmmmw_count_other: "'week' W 'of' MMMM",
mmmmw_count_one: "'week' W 'of' MMMM",
mmm_ed: "E, MMM d",
y_mmm_ed: "E, MMM d, y",
md: "M/d",
gy_mmm_ed: "E, MMM d, y G",
d: "d",
e_hms: "E HH:mm:ss",
hmsv: "h:mm:ss a v",
m: "L",
ms: "mm:ss",
y_qqqq: "QQQQ y",
y_mmm: "MMM y",
m_ed: "E, M/d",
bh: "h B",
y_qqq: "QQQ y",
ed: "d E",
yw_count_one: "'week' w 'of' Y"
}}
date_time_formats(Cldr.Locale.name() | Cldr.LanguageTag, calendar()) :: standard_formats()
Returns a map of the standard datetime formats for a given locale and calendar.
locale
is any locale returned byCldr.known_locale_names/0
calendar
is any calendar returned byCldr.DateTime.Format.calendars_for/1
The default is:gregorian
Examples:
iex> Cldr.DateTime.Format.date_time_formats "en"
{:ok, %Cldr.DateTime.Formats{
full: "{1} 'at' {0}",
long: "{1} 'at' {0}",
medium: "{1}, {0}",
short: "{1}, {0}"
}}
iex> Cldr.DateTime.Format.date_time_formats "en", :buddhist
{:ok, %Cldr.DateTime.Formats{
full: "{1} 'at' {0}",
long: "{1} 'at' {0}",
medium: "{1}, {0}",
short: "{1}, {0}"
}}
Returns a list of all formats defined for the configured locales.
gmt_format(Cldr.Locale.name() | Cldr.LanguageTag) :: [ non_neg_integer() | String.t(), ... ]
Returns the GMT offset format list for a for a timezone offset for a given locale.
locale
is any locale returned byCldr.known_locale_names/0
Example
iex> Cldr.DateTime.Format.gmt_format "en"
{:ok, ["GMT", 0]}
gmt_zero_format(Cldr.Locale.name() | Cldr.LanguageTag) :: String.t()
Returns the GMT format string for a for a timezone with an offset of zero for a given locale.
locale
is any locale returned byCldr.known_locale_names/0
Example
iex> Cldr.DateTime.Format.gmt_zero_format "en"
{:ok, "GMT"}
hour_format(Cldr.Locale.name() | Cldr.LanguageTag) :: {String.t(), String.t()}
Returns the postive and negative hour format for a timezone offset for a given locale.
locale
is any locale returned byCldr.known_locale_names/0
Example
iex> Cldr.DateTime.Format.hour_format "en"
{:ok, {"+HH:mm", "-HH:mm"}}
time_formats(Cldr.Locale.name() | Cldr.LanguageTag, calendar()) :: standard_formats()
Returns a map of the standard time formats for a given locale and calendar.
locale
is any locale returned byCldr.known_locale_names/0
calendar
is any calendar returned byCldr.DateTime.Format.calendars_for/1
The default is:gregorian
Examples:
iex> Cldr.DateTime.Format.time_formats "en"
{:ok, %Cldr.Time.Formats{
full: "h:mm:ss a zzzz",
long: "h:mm:ss a z",
medium: "h:mm:ss a",
short: "h:mm a"
}}
iex> Cldr.DateTime.Format.time_formats "en", :buddhist
{:ok, %Cldr.Time.Formats{
full: "h:mm:ss a zzzz",
long: "h:mm:ss a z",
medium: "h:mm:ss a",
short: "h:mm a"
}}