Sha256: 789d45b2a3b31c8d55d075ef2b95f4ae890e6c159b37de9713a43216b5a21b42

Contents?: true

Size: 697 Bytes

Versions: 5

Compression:

Stored size: 697 Bytes

Contents

module Chronic
  class TimeZone < Tag

    # Scan an Array of {Token}s and apply any necessary TimeZone tags to
    # each token
    #
    # @param [Array<Token>] tokens Array of tokens to scan
    # @param [Hash] options Options specified in {Chronic.parse}
    # @return [Array] list of tokens
    def self.scan(tokens, options)
      tokens.each do |token|
        if t = scan_for_all(token) then token.tag(t); next end
      end
    end

    # @param [Token] token
    # @return [TimeZone, nil]
    def self.scan_for_all(token)
      scan_for token, self,
      {
        /[PMCE][DS]T/i => :tz,
        /(tzminus)?\d{4}/ => :tz
      }
    end

    def to_s
      'timezone'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
chronic-0.6.1 lib/chronic/time_zone.rb
chronic-0.6.0 lib/chronic/time_zone.rb
chronic-0.5.0 lib/chronic/time_zone.rb
chronic-0.4.4 lib/chronic/time_zone.rb
chronic-0.4.3 lib/chronic/time_zone.rb