Class: Integer
- Inherits:
-
Object
- Object
- Integer
- Defined in:
- lib/cotcube-helpers/swig/date.rb
Instance Method Summary collapse
- #to_date ⇒ Object
- #to_time ⇒ Object
- #to_tod(zone = "UTC") ⇒ Object
- #to_tod_i ⇒ Object
- #to_tz ⇒ Object
Instance Method Details
#to_date ⇒ Object
57 58 59 |
# File 'lib/cotcube-helpers/swig/date.rb', line 57 def to_date Date::strptime(self.to_s, "%s") end |
#to_time ⇒ Object
61 62 63 |
# File 'lib/cotcube-helpers/swig/date.rb', line 61 def to_time DateTime.strptime(self.to_s, "%s") end |
#to_tod(zone = "UTC") ⇒ Object
47 48 49 50 51 |
# File 'lib/cotcube-helpers/swig/date.rb', line 47 def to_tod(zone="UTC") self.to_time #in_time_zone(zone). #to_time_of_day end |
#to_tod_i ⇒ Object
53 54 55 |
# File 'lib/cotcube-helpers/swig/date.rb', line 53 def to_tod_i (self / 100).to_time.strftime("%H%M%S").to_i end |
#to_tz ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/cotcube-helpers/swig/date.rb', line 38 def to_tz return "+0000" if self == 0 sign = self > 0 ? "+" : "-" value = self.abs hours = (value / 3600.to_f).floor minutes = ((value - 3600 * hours) / 60).floor "#{sign}#{hours>9 ? "" : "0"}#{hours}#{minutes<10 ? "0" : "" }#{minutes}" end |