Class: TwitterCldr::Formatters::DateTimeFormatter
- Defined in:
- lib/twitter_cldr/formatters/calendars/datetime_formatter.rb
Direct Known Subclasses
Constant Summary collapse
- WEEKDAY_KEYS =
[:sun, :mon, :tue, :wed, :thu, :fri, :sat]
- METHODS =
ignoring u, l, g, j, A
{ # ignoring u, l, g, j, A 'G' => :era, 'y' => :year, 'Y' => :year_of_week_of_year, 'Q' => :quarter, 'q' => :quarter_stand_alone, 'M' => :month, 'L' => :month_stand_alone, 'w' => :week_of_year, 'W' => :week_of_month, 'd' => :day, 'D' => :day_of_month, 'F' => :day_of_week_in_month, 'E' => :weekday, 'e' => :weekday_local, 'c' => :weekday_local_stand_alone, 'a' => :period, 'h' => :hour, 'H' => :hour, 'K' => :hour, 'k' => :hour, 'm' => :minute, 's' => :second, 'S' => :second_fraction, 'z' => :timezone, 'Z' => :timezone, 'v' => :timezone_generic_non_location, 'V' => :timezone_metazone }
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #additional_format_selector ⇒ Object
-
#initialize(options = {}) ⇒ DateTimeFormatter
constructor
A new instance of DateTimeFormatter.
- #result_for_token(token, index, date, options = {}) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(options = {}) ⇒ DateTimeFormatter
Returns a new instance of DateTimeFormatter.
45 46 47 48 49 50 51 52 |
# File 'lib/twitter_cldr/formatters/calendars/datetime_formatter.rb', line 45 def initialize( = {}) locale = extract_locale() cache_key = TwitterCldr::Utils.compute_cache_key("datetime", locale, [:calendar_type]) @tokenizer = tokenizer_cache[cache_key] ||= TwitterCldr::Tokenizers::DateTimeTokenizer.new( :locale => locale, :calendar_type => [:calendar_type] ) end |
Class Method Details
.additional_formats_for(locale) ⇒ Object
62 63 64 |
# File 'lib/twitter_cldr/formatters/calendars/datetime_formatter.rb', line 62 def self.additional_formats_for(locale) new(:locale => locale).additional_format_selector.patterns.map(&:to_s) end |
Instance Method Details
#additional_format_selector ⇒ Object
58 59 60 |
# File 'lib/twitter_cldr/formatters/calendars/datetime_formatter.rb', line 58 def additional_format_selector @tokenizer.additional_format_selector end |
#result_for_token(token, index, date, options = {}) ⇒ Object
54 55 56 |
# File 'lib/twitter_cldr/formatters/calendars/datetime_formatter.rb', line 54 def result_for_token(token, index, date, = {}) self.send(METHODS[token.value[0].chr], date, token.value, token.value.size, ) end |