Class: TwitterCldr::Localized::LocalizedDate
- Inherits:
-
LocalizedDateTime
- Object
- LocalizedObject
- LocalizedDateTime
- TwitterCldr::Localized::LocalizedDate
- Defined in:
- lib/twitter_cldr/localized/localized_date.rb
Instance Attribute Summary
Attributes inherited from LocalizedDateTime
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
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 25 26 27 28 29 30 31 32 33 34 35 36 |
# 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 DateTime utc_dt = @base_obj.new_offset(0) time = Time.gm( utc_dt.year, utc_dt.month, utc_dt.day, utc_dt.hour, utc_dt.min, utc_dt.sec, utc_dt.sec_fraction * (RUBY_VERSION < '1.9' ? 86400000000 : 1000000) ) LocalizedTime.new(time, @locale, chain_params) else nil end end |