Sha256: 9024e63596d958ca4e5bdd97354f29001c1f480304f816b541405a283a889553

Contents?: true

Size: 1.45 KB

Versions: 6

Compression:

Stored size: 1.45 KB

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

module TwitterCldr
  module Js
    module Renderers
      module Calendars
        class DateTimeRenderer < TwitterCldr::Js::Renderers::Base
          self.template_file = File.expand_path(File.join(File.dirname(__FILE__), "../..", "mustache/calendars/datetime.coffee"))

          def tokens
            { :date_time => TwitterCldr::Tokenizers::DateTimeTokenizer,
              :time => TwitterCldr::Tokenizers::TimeTokenizer,
              :date => TwitterCldr::Tokenizers::DateTokenizer }.inject({}) do |tokens, (name, const)|
              tokenizer = const.new(:locale => @locale)
              tokens[name] = const::VALID_TYPES.inject({}) do |ret, type|
                ret[type] = if type == :additional
                  pattern_list = TwitterCldr.get_locale_resource(@locale, :calendars)[@locale][:calendars]
                  pattern_list = pattern_list[tokenizer.calendar_type][:additional_formats].keys
                  pattern_list.inject({}) do |additionals, pattern|
                    additionals[pattern] = tokenizer.tokens(:type => type, :format => pattern.to_s).map(&:to_hash)
                    additionals
                  end
                else
                  tokenizer.tokens(:type => type).map(&:to_hash)
                end
                ret
              end
              tokens
            end.to_json
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
twitter_cldr_js-2.2.4 lib/twitter_cldr/js/renderers/calendars/datetime_renderer.rb
twitter_cldr_js-2.2.3 lib/twitter_cldr/js/renderers/calendars/datetime_renderer.rb
twitter_cldr_js-2.2.2 lib/twitter_cldr/js/renderers/calendars/datetime_renderer.rb
twitter_cldr_js-2.2.0 lib/twitter_cldr/js/renderers/calendars/datetime_renderer.rb
twitter_cldr_js-2.1.0 lib/twitter_cldr/js/renderers/calendars/datetime_renderer.rb
twitter_cldr_js-2.0.0 lib/twitter_cldr/js/renderers/calendars/datetime_renderer.rb