Cldr Calendars Format v0.4.0 Cldr.Calendar.Formatter behaviour View Source

Calendar formatter behaviour.

This behaviour defines a set of callbacks that are invoked during the formatting of a calendar.

At each point in the formatting process the callbacks are invoked from the "inside out". That is, format_day/4 is invoked for each day of the week, then format_week/5 is called, then format_month/4 and finally format_year/3 is called if required.

Link to this section Summary

Callbacks

Returns the formatted calendar for a day

Returns the formatted calendar for a month

Returns the formatted calendar for a week

Returns the formatted calendar for a year

Link to this section Callbacks

Link to this callback

format_day(date, year, month, options)

View Source
format_day(
  date :: Date.t(),
  year :: Calendar.year(),
  month :: Calendar.month(),
  options :: Cldr.Calendar.Formatter.Options.t()
) :: any()

Returns the formatted calendar for a day

Arguments

  • formatted_months is the result returned by format_month/4

  • year is the year for which the calendar is requested

  • month is the month for which the calendar is requested

  • options is a Cldr.Calendar.Formatter.Options struct

Returns

  • An arbitrary result as required which is passed to format_week/5
Link to this callback

format_month(formatted_weeks, year, month, options)

View Source
format_month(
  formatted_weeks :: String.t(),
  year :: Calendar.year(),
  month :: Calendar.month(),
  options :: Keyword.t() | Cldr.Calendar.Formatter.Options.t()
) :: any()

Returns the formatted calendar for a month

Arguments

  • formatted_weeks is the result returned by format_week/5

  • year is the year for which the calendar is requested

  • month is the month for which the calendar is requested

  • options is a Cldr.Calendar.Formatter.Options struct

Returns

Link to this callback

format_week(formatted_days, year, month, week_number, options)

View Source
format_week(
  formatted_days :: String.t(),
  year :: Calendar.year(),
  month :: Calendar.month(),
  week_number :: {Calendar.year(), pos_integer()},
  options :: Cldr.Calendar.Formatter.Options.t()
) :: any()

Returns the formatted calendar for a week

Arguments

  • formatted_days is the result returned by format_day/4

  • year is the year for which the calendar is requested

  • month is the month for which the calendar is requested

  • week_number is a 2-tuple of the form {year, week_number} that represents the week of year for week to be formatted

  • options is a Cldr.Calendar.Formatter.Options struct

Returns

  • An arbitrary result as required which is passed to format_month/4
Link to this callback

format_year(formatted_months, year, options)

View Source
format_year(
  formatted_months :: String.t(),
  year :: Calendar.year(),
  options :: Keyword.t() | Cldr.Calendar.Formatter.Options.t()
) :: any()

Returns the formatted calendar for a year

Arguments

  • formatted_months is the result returned by format_month/4

  • year is the year for which the calendar is requested

  • month is the month for which the calendar is requested

  • options is a Cldr.Calendar.Formatter.Options struct

Returns

  • An arbitrary result as required.