summaryrefslogtreecommitdiff
path: root/lib/date2.rb
diff options
context:
space:
mode:
author(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-10 08:44:29 +0000
committer(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-10 08:44:29 +0000
commit6e3a72afccaa2bcd1b44a447c179bd81c27ac567 (patch)
treef99563ed31c2f6a8facc7160cccde602d39af79b /lib/date2.rb
parent62e648e148b3cb9f96dcce808c55c02b7ccb4486 (diff)
This commit was manufactured by cvs2svn to create tag
'v1_3_1_990210'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_3_1_990210@399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/date2.rb')
-rw-r--r--lib/date2.rb24
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/date2.rb b/lib/date2.rb
index 50c2ccfbd9..6e87824b38 100644
--- a/lib/date2.rb
+++ b/lib/date2.rb
@@ -1,11 +1,11 @@
-# date.rb: Written by Tadayoshi Funaba 1998
-# $Id: date.rb,v 1.4 1998/06/01 12:52:33 tadf Exp $
+# date.rb: Written by Tadayoshi Funaba 1998, 1999
+# $Id: date.rb,v 1.5 1999/02/06 08:51:56 tadf Exp $
class Date
include Comparable
- MONTHNAMES = [ '', 'January', 'February', 'March', 'April', 'May', 'June',
+ MONTHNAMES = [ nil, 'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December' ]
DAYNAMES = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
@@ -162,26 +162,24 @@ class Date
end
def + (other)
- if other.kind_of? Numeric then
- return Date.new(@jd + other, @gs)
+ case other
+ when Numeric; return Date.new(@jd + other, @gs)
end
fail TypeError, 'expected numeric'
end
def - (other)
- if other.kind_of? Numeric then
- return Date.new(@jd - other, @gs)
- elsif other.kind_of? Date then
- return @jd - other.jd
+ case other
+ when Numeric; return Date.new(@jd - other, @gs)
+ when Date; return @jd - other.jd
end
fail TypeError, 'expected numeric or date'
end
def <=> (other)
- if other.kind_of? Numeric then
- return @jd <=> other
- elsif other.kind_of? Date then
- return @jd <=> other.jd
+ case other
+ when Numeric; return @jd <=> other
+ when Date; return @jd <=> other.jd
end
fail TypeError, 'expected numeric or date'
end