Class: Foxtail::Function::DateTime
- Defined in:
- lib/foxtail/function/datetime.rb
Overview
Wraps a datetime value with formatting options The raw value is preserved for selector matching
Instance Attribute Summary
Attributes inherited from Value
Class Method Summary collapse
-
.convert_options(options) ⇒ Hash
Convert FTL/JS style datetime options to ICU4X options.
Instance Method Summary collapse
-
#format(bundle:) ⇒ String
Format the datetime using ICU4X.
Methods inherited from Value
Class Method Details
.convert_options(options) ⇒ Hash
Convert FTL/JS style datetime options to ICU4X options
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/foxtail/function/datetime.rb', line 11 def self.() result = {} .each do |key, value| case key when :dateStyle result[:date_style] = value.to_sym when :timeStyle result[:time_style] = value.to_sym when :timeZone result[:time_zone] = value.to_s else warn "Unknown DATETIME option: #{key}" end end result end |
Instance Method Details
#format(bundle:) ⇒ String
Format the datetime using ICU4X
33 34 35 36 |
# File 'lib/foxtail/function/datetime.rb', line 33 def format(bundle:) = self.class.() ICU4XCache.instance.datetime_formatter(bundle.locale, **).format(value) end |