Module: TimeCrisis::Support::Conversions::String
- Defined in:
- lib/time_crisis/support/conversions.rb
Instance Method Summary collapse
Instance Method Details
#to_date ⇒ Object
53 54 55 |
# File 'lib/time_crisis/support/conversions.rb', line 53 def to_date ::Date.civil(*::Date._parse(self, false).values_at(:year, :mon, :mday)) end |
#to_datetime ⇒ Object
57 58 59 60 61 |
# File 'lib/time_crisis/support/conversions.rb', line 57 def to_datetime d = ::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec, :zone, :sec_fraction).map { |arg| arg || 0 } d[5] += d.pop ::DateTime.civil(*d) end |
#to_time(form = :utc) ⇒ Object
47 48 49 50 51 |
# File 'lib/time_crisis/support/conversions.rb', line 47 def to_time(form = :utc) d = ::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec, :sec_fraction).map { |arg| arg || 0 } d[6] *= 1000000 ::Time.send(form, *d) end |