summaryrefslogtreecommitdiff
path: root/lib/date2.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-09-01 09:48:03 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-09-01 09:48:03 +0000
commit69a3aaf154948d653fa3653cd2b3c3b3af979769 (patch)
treef83116ebca291337b9948831c617217c18f6a317 /lib/date2.rb
parenta1b57d0add85a248666fb55c58aa8c0c772136fc (diff)
regexp literal (e.g. \202) match, etc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/date2.rb')
-rw-r--r--lib/date2.rb25
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/date2.rb b/lib/date2.rb
index 58bfbe5..cc5e7f4 100644
--- a/lib/date2.rb
+++ b/lib/date2.rb
@@ -1,5 +1,5 @@
# date2.rb: Written by Tadayoshi Funaba 1998, 1999
-# $Id: date2.rb,v 1.13 1999/08/11 01:10:02 tadf Exp $
+# $Id: date2.rb,v 1.15 1999/08/29 15:23:52 tadf Exp $
class Date
@@ -31,10 +31,10 @@ class Date
y -= 1
m += 12
end
- a = (y / 100).to_i
- b = 2 - a + (a / 4).to_i
- jd = (365.25 * (y + 4716)).to_i +
- (30.6001 * (m + 1)).to_i +
+ a = (y / 100.0).floor
+ b = 2 - a + (a / 4.0).floor
+ jd = (365.25 * (y + 4716)).floor +
+ (30.6001 * (m + 1)).floor +
d + b - 1524
if os?(jd, sg)
jd -= b
@@ -46,14 +46,14 @@ class Date
if os?(jd, sg)
a = jd
else
- x = ((jd - 1867216.25) / 36524.25).to_i
- a = jd + 1 + x - (x / 4).to_i
+ x = ((jd - 1867216.25) / 36524.25).floor
+ a = jd + 1 + x - (x / 4.0).floor
end
b = a + 1524
- c = ((b - 122.1) / 365.25).to_i
- d = (365.25 * c).to_i
- e = ((b - d) / 30.6001).to_i
- dom = b - d - (30.6001 * e).to_i
+ c = ((b - 122.1) / 365.25).floor
+ d = (365.25 * c).floor
+ e = ((b - d) / 30.6001).floor
+ dom = b - d - (30.6001 * e).floor
if e <= 13
m = e - 1
y = c - 4716
@@ -70,8 +70,7 @@ class Date
def jd_to_ordinal(jd, sg=true)
y = jd_to_civil(jd, sg)[0]
- pl = civil_to_jd(y - 1, 12, 31, ns?(jd, sg))
- doy = jd - pl
+ doy = jd - civil_to_jd(y - 1, 12, 31, ns?(jd, sg))
return y, doy
end