1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05: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:
tadf 2009-10-18 13:38:55 +00:00
parent a07cef02a9
commit a542b9248e
3 changed files with 38 additions and 8 deletions

View file

@ -1,3 +1,9 @@
Sun Oct 18 22:33:25 2009 Tadayoshi Funaba <tadf@dotrb.org>
* lib/date.rb: do not require lib/delta.rb.
* lib/date/delta.rb: follows the above change.
Sun Oct 18 19:14:21 2009 Tanaka Akira <akr@fsij.org> Sun Oct 18 19:14:21 2009 Tanaka Akira <akr@fsij.org>
* parse.y (is_special_global_name): add boundary check. * parse.y (is_special_global_name): add boundary check.

View file

@ -194,7 +194,6 @@
# puts secs_to_new_year() # puts secs_to_new_year()
require 'date/format' require 'date/format'
require 'date/delta'
# Class representing a date. # Class representing a date.
# #
@ -1337,9 +1336,6 @@ class Date
def + (n) def + (n)
case n case n
when Numeric; return self.class.new!(@ajd + n, @of, @sg) when Numeric; return self.class.new!(@ajd + n, @of, @sg)
when Delta
d = n.__send__(:delta)
return (self >> d.imag) + d.real
end end
raise TypeError, 'expected numeric' raise TypeError, 'expected numeric'
end end
@ -1356,11 +1352,8 @@ class Date
case x case x
when Numeric; return self.class.new!(@ajd - x, @of, @sg) when Numeric; return self.class.new!(@ajd - x, @of, @sg)
when Date; return @ajd - x.ajd when Date; return @ajd - x.ajd
when Delta
d = x.__send__(:delta)
return (self << d.imag) - d.real
end end
raise TypeError, 'expected numeric' raise TypeError, 'expected numeric or date'
end end
# Compare this date with another date. # Compare this date with another date.

View file

@ -1,5 +1,6 @@
# delta.rb: Written by Tadayoshi Funaba 2004-2009 # delta.rb: Written by Tadayoshi Funaba 2004-2009
require 'date'
require 'date/delta/parser' require 'date/delta/parser'
class Date class Date
@ -398,3 +399,33 @@ class Date
end end
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