Sha256: 75eac94573c621fed2642b539d893ba384808b285282a1623509eb081d79b007

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

require 'date'
require 'forwardable'

require 'timeliness/helpers'
require 'timeliness/definitions'
require 'timeliness/format'
require 'timeliness/format_set'
require 'timeliness/parser'
require 'timeliness/version'

module Timeliness
  class << self
    extend Forwardable
    def_delegators Parser, :parse, :_parse
    def_delegators Definitions, :add_formats, :remove_formats, :use_us_formats, :use_euro_formats
    attr_accessor :default_timezone, :date_for_time_type, :ambiguous_year_threshold
  end

  # Default timezone. Options:
  #   - :local (default)
  #   - :utc
  #   
  #   If ActiveSupport loaded, also
  #   - :current
  #   - 'Zone name'
  #
  @default_timezone = :local

  # Set the default date part for a time type values.
  @date_for_time_type = lambda { Time.now }

  def self.date_for_time_type
    case @date_for_time_type
    when Array
      @date_for_time_type
    when Proc
      v = @date_for_time_type.call
      [v.year, v.month, v.day]
    end
  end

  # Set the threshold value for a two digit year to be considered last century
  #
  # Default: 30
  #
  #   Example:
  #     year = '29' is considered 2029
  #     year = '30' is considered 1930
  #
  @ambiguous_year_threshold = 30
end

Timeliness::Definitions.compile_formats

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
timeliness-0.3.6 lib/timeliness.rb
timeliness-0.3.5 lib/timeliness.rb
timeliness-0.3.4 lib/timeliness.rb
timeliness-0.3.3 lib/timeliness.rb
timeliness-0.3.2 lib/timeliness.rb
timeliness-0.3.1 lib/timeliness.rb
timeliness-0.3.0 lib/timeliness.rb