class TwitterCldr::Localized::LocalizedDate

Public Instance Methods

to_datetime(time = Time.now) click to toggle source
# File lib/twitter_cldr/localized/localized_date.rb, line 10
def to_datetime(time = Time.now)
  dt = DateTime.parse("#{@base_obj.strftime("%Y-%m-%d")}T#{unwrap_time_obj(time).strftime("%H:%M:%S%z")}")
  LocalizedDateTime.new(dt, @locale, chain_params)
end
to_time(base = Time.now) click to toggle source
# File lib/twitter_cldr/localized/localized_date.rb, line 15
def to_time(base = Time.now)
  case @base_obj
    when Time
      LocalizedTime.new(@base_obj, @locale, chain_params)
    when Date, DateTime
      LocalizedTime.new(@base_obj.to_time, @locale, chain_params)
    else
      nil
  end
end

Protected Instance Methods

base_in_timezone() click to toggle source
# File lib/twitter_cldr/localized/localized_date.rb, line 32
def base_in_timezone
  time = unwrap_time_obj(to_time)
  timezone_info.utc_to_local(time.is_a?(DateTime) ? time.new_offset(0) : time.utc)
end
data_reader_for(type, options = {}) click to toggle source
# File lib/twitter_cldr/localized/localized_date.rb, line 37
def data_reader_for(type, options = {})
  TwitterCldr::DataReaders::DateDataReader.new(
    locale, options.merge({
      calendar_type: calendar_type,
      type: type
    })
  )
end
unwrap_time_obj(time) click to toggle source
# File lib/twitter_cldr/localized/localized_date.rb, line 28
def unwrap_time_obj(time)
  time.is_a?(LocalizedTime) ? time.base_obj : time
end