Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/ruby_units/date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Date
# @return [Unit]
def +(unit)
case unit
when Unit
when RubyUnits::Unit
unit = unit.convert_to('d').round if ['y', 'decade', 'century'].include? unit.units
unit_date_add(unit.convert_to('day').scalar)
else
Expand All @@ -21,7 +21,7 @@ def +(unit)
# @return [Unit]
def -(unit)
case unit
when Unit
when RubyUnits::Unit
unit = unit.convert_to('d').round if ['y', 'decade', 'century'].include? unit.units
unit_date_sub(unit.convert_to('day').scalar)
else
Expand All @@ -34,7 +34,7 @@ def -(unit)
# @return (see Unit#initialize)
# @param [Object] other convert to same units as passed
def to_unit(other = nil)
other ? Unit.new(self).convert_to(other) : Unit.new(self)
other ? RubyUnits::Unit.new(self).convert_to(other) : RubyUnits::Unit.new(self)
end
alias :unit :to_unit

Expand Down Expand Up @@ -63,4 +63,4 @@ def to_date
# :nocov_19:
end

end
end