Skip to content

Commit

Permalink
Fix Time#+ and Time#-
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Oct 24, 2013
1 parent c723073 commit 33264fb
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions corelib/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,24 @@ def self.parse(str)
end

def +(other)
Time.allocate(self.to_f + other.to_f)
%x{
if (other._isNumber) {
return new Date(self.getTime() + (other * 1000));
}
}

raise TypeError, "Time#+"
end

def -(other)
Time.allocate(self.to_f - other.to_f)
%x{
if (other._isNumber) {
return new Date(self.getTime() - (other * 1000));
}
else {
return (self.getTime() - other.getTime()) / 1000;
}
}
end

def <=>(other)
Expand Down

0 comments on commit 33264fb

Please sign in to comment.