mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
* lib/date.rb: do not require lib/delta.rb.
* lib/date/delta.rb: follows the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a07cef02a9
commit
a542b9248e
3 changed files with 38 additions and 8 deletions
|
@ -1,5 +1,6 @@
|
|||
# delta.rb: Written by Tadayoshi Funaba 2004-2009
|
||||
|
||||
require 'date'
|
||||
require 'date/delta/parser'
|
||||
|
||||
class Date
|
||||
|
@ -398,3 +399,33 @@ class Date
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
vsave = $VERBOSE
|
||||
$VERBOSE = false
|
||||
|
||||
class Date
|
||||
|
||||
def + (n)
|
||||
case n
|
||||
when Numeric; return self.class.new!(@ajd + n, @of, @sg)
|
||||
when Delta
|
||||
d = n.__send__(:delta)
|
||||
return (self >> d.imag) + d.real
|
||||
end
|
||||
raise TypeError, 'expected numeric'
|
||||
end
|
||||
|
||||
def - (x)
|
||||
case x
|
||||
when Numeric; return self.class.new!(@ajd - x, @of, @sg)
|
||||
when Date; return @ajd - x.ajd
|
||||
when Delta
|
||||
d = x.__send__(:delta)
|
||||
return (self << d.imag) - d.real
|
||||
end
|
||||
raise TypeError, 'expected numeric'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
$VERBOSE = vsave
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue