Sha256: 03528cb894fd5c38e246eece690821a351b5fc1519b142dc7b72d7e2476a8b5c

Contents?: true

Size: 1.16 KB

Versions: 12

Compression:

Stored size: 1.16 KB

Contents

# encoding: UTF-8

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

module TwitterCldr
  module Tokenizers
    class DateTokenizer < TwitterCldr::Tokenizers::DateTimeTokenizer
      def initialize(options = {})
        super(options)
        @token_splitter_regex = /(\s*\'[\w\s-]+\'\s*|G{1,5}|y+|Y+|Q{1,4}|q{1,5}|M{1,5}|L{1,5}|d{1,2}|F{1}|E{1,5}|e{1,5}|c{1,5}|\#\{[^\}]+\})/

        @token_type_regexes = [
            { :type => :composite, :regex => /^\#\{[^\}]+\}/, :content => /^\#\{([^\}]+)\}/ },
            { :type => :pattern,   :regex => /^(?:G{1,5}|y+|Y+|Q{1,4}|q{1,5}|M{1,5}|L{1,5}|d{1,2}|F{1}|E{1,5}|e{1,5}|c{1,5})/ },
            { :type => :plaintext, :regex => // }
        ]

        @paths = {
            :default => [:formats, :date, :default],
            :full    => [:formats, :date, :full],
            :long    => [:formats, :date, :long],
            :medium  => [:formats, :date, :medium],
            :short   => [:formats, :date, :short]
        }
      end

      protected

      # must override this because DateTimeTokenizer will set them otherwise
      def init_placeholders
        @placeholders = {}
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
twitter_cldr-1.9.1 lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb
twitter_cldr-1.9.0 lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb
twitter_cldr-1.8.1 lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb
twitter_cldr-1.8.0 lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb
twitter_cldr-1.7.0 lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb
twitter_cldr-1.6.2 lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb
twitter_cldr-1.6.1 lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb
twitter_cldr-1.6.0 lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb
twitter_cldr-1.5.0 lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb
twitter_cldr-1.4.1 lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb
twitter_cldr-1.4.0 lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb
twitter_cldr-1.3.6 lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb