Class: Time

Inherits:
Object
  • Object
show all
Defined in:
lib/abstractive/timespans.rb

Instance Method Summary collapse

Instance Method Details

#+(x) ⇒ Object



126
127
128
129
130
131
132
133
134
# File 'lib/abstractive/timespans.rb', line 126

def +(x)
   case x
     when Days;      return Abstractive::TimeSpans.plus_span(self, x.to_seconds).to_time
     when Hours;     return DateTime.new(year, month, day, hour+x.to_i, min, sec, strftime("%:z")).to_time
     when Minutes;   return DateTime.new(year, month, day, hour, min+x.to_i, sec, strftime("%:z")).to_time
     when Seconds;   return DateTime.new(year, month, day, hour, min, sec+x.to_i, strftime("%:z")).to_time
     else;           return self.old_add(x)
   end
end

#-(x) ⇒ Object



117
118
119
120
121
122
123
124
125
# File 'lib/abstractive/timespans.rb', line 117

def -(x)
   case x
     when Days;      return Abstractive::TimeSpans.minus_span(self, x.to_seconds).to_time
     when Hours;     return DateTime.new(year, month, day, hour-x.to_i, min, sec, strftime("%:z")).to_time
     when Minutes;   return DateTime.new(year, month, day, hour, min-x.to_i, sec, strftime("%:z")).to_time
     when Seconds;   return DateTime.new(year, month, day, hour, min, sec-x.to_i, strftime("%:z")).to_time
     else;           return self.old_subtract(x)
   end
end

#old_addObject



116
# File 'lib/abstractive/timespans.rb', line 116

alias old_add +

#old_subtractObject



115
# File 'lib/abstractive/timespans.rb', line 115

alias old_subtract -