Class: Worldwide::TimeFormatter
- Inherits:
-
Object
- Object
- Worldwide::TimeFormatter
- Defined in:
- lib/worldwide/time_formatter.rb
Instance Method Summary collapse
- #hour_minute_separator ⇒ Object
-
#initialize(locale: I18n.locale) ⇒ TimeFormatter
constructor
A new instance of TimeFormatter.
- #twelve_hour_clock? ⇒ Boolean
Constructor Details
#initialize(locale: I18n.locale) ⇒ TimeFormatter
Returns a new instance of TimeFormatter.
5 6 7 |
# File 'lib/worldwide/time_formatter.rb', line 5 def initialize(locale: I18n.locale) @locale = locale end |
Instance Method Details
#hour_minute_separator ⇒ Object
9 10 11 12 |
# File 'lib/worldwide/time_formatter.rb', line 9 def hour_minute_separator format_string = Worldwide::Cldr.t("time.formats.time_only", locale: @locale) /%\-?\d?\d?[Akl](.*)%\-?\d?\d?M/.match(format_string)&.captures&.first || ":" end |
#twelve_hour_clock? ⇒ Boolean
14 15 16 |
# File 'lib/worldwide/time_formatter.rb', line 14 def twelve_hour_clock? Worldwide::Cldr.t("time.formats.time_only", locale: @locale)&.include?("%P") end |