Class: TwitterCldr::Formatters::DateTimeFormatter

Inherits:
Base
  • Object
show all
Defined in:
lib/twitter_cldr/formatters/calendars/datetime_formatter.rb

Direct Known Subclasses

DateFormatter, TimeFormatter

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

#tokenizer

Instance Method Summary collapse

Methods inherited from Base

#format

Constructor Details

#initialize(options = {}) ⇒ DateTimeFormatter

Returns a new instance of DateTimeFormatter.



43
44
45
# File 'lib/twitter_cldr/formatters/calendars/datetime_formatter.rb', line 43

def initialize(options = {})
  @tokenizer = TwitterCldr::Tokenizers::DateTimeTokenizer.new(:locale => extract_locale(options), :calendar_type => options[:calendar_type])
end

Instance Method Details

#result_for_token(token, index, date) ⇒ Object



47
48
49
# File 'lib/twitter_cldr/formatters/calendars/datetime_formatter.rb', line 47

def result_for_token(token, index, date)
  self.send(METHODS[token.value[0].chr], date, token.value, token.value.size)
end