Class: Worldwide::Calendar::Gregorian

Inherits:
Object
  • Object
show all
Defined in:
lib/worldwide/calendar/gregorian.rb

Constant Summary collapse

VALID_WEEKDAY_WIDTHS =

We intentionally don’t support ‘short` weekday names, as we haven’t found anyone asking for them. People usually want the full weekday name, or the abbreviated version.

[:abbreviated, :narrow, :wide].freeze
VALID_MONTH_WIDTHS =
[:abbreviated, :narrow, :wide].freeze

Class Method Summary collapse

Class Method Details

.month_names(width: :wide, locale: I18n.locale) ⇒ Object

Raises:

  • (ArgumentError)


17
18
19
20
21
# File 'lib/worldwide/calendar/gregorian.rb', line 17

def month_names(width: :wide, locale: I18n.locale)
  raise ArgumentError, "Invalid width: #{width}" unless VALID_MONTH_WIDTHS.include?(width)

  Worldwide::Cldr.t("calendars.gregorian.months.stand_alone.#{width}", locale: locale).values
end

.quarter(date, locale: I18n.locale) ⇒ Object



23
24
25
26
# File 'lib/worldwide/calendar/gregorian.rb', line 23

def quarter(date, locale: I18n.locale)
  format_string = Worldwide::Cldr.t("calendars.gregorian.additional_formats.yQQQ", locale: locale)
  Worldwide::Cldr::DateFormatPattern.format(date, format_string, locale: locale)
end

.weekday_names(width: :wide, locale: I18n.locale) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
# File 'lib/worldwide/calendar/gregorian.rb', line 10

def weekday_names(width: :wide, locale: I18n.locale)
  raise ArgumentError, "Invalid width: #{width}" unless VALID_WEEKDAY_WIDTHS.include?(width)

  Worldwide::Cldr.t("calendars.gregorian.days.stand_alone.#{width}", locale: locale)
end