Class: Integer

Inherits:
Object
  • Object
show all
Defined in:
lib/cotcube-helpers/swig/date.rb

Instance Method Summary collapse

Instance Method Details

#to_dateObject



57
58
59
# File 'lib/cotcube-helpers/swig/date.rb', line 57

def to_date
  Date::strptime(self.to_s, "%s")
end

#to_timeObject



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_iObject



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_tzObject



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