Class: TwitterCldr::Localized::LocalizedDate

Inherits:
LocalizedDateTime show all
Defined in:
lib/twitter_cldr/localized/localized_date.rb

Instance Attribute Summary

Attributes inherited from LocalizedDateTime

#calendar_type, #timezone

Attributes inherited from LocalizedObject

#base_obj, #formatter, #locale

Instance Method Summary collapse

Methods inherited from LocalizedDateTime

#additional_formats, #ago, #initialize, #to_additional_s, #to_date, #to_s, #to_timespan, types, #until, #with_timezone

Methods inherited from LocalizedObject

#initialize, localize

Constructor Details

This class inherits a constructor from TwitterCldr::Localized::LocalizedDateTime

Instance Method Details

#to_datetime(time = Time.now) ⇒ Object



10
11
12
13
# 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) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# 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