diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-08-11 07:24:11 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-08-11 07:24:11 +0000 |
commit | c5fb7cf4fb7759ae020032f344460c2accef2bc7 (patch) | |
tree | 37621427e11c9e2bf672c05c25b24bf0d365a639 /sample | |
parent | b0faee9b9cd5a747e226a2c64f33588b2b8f4e6c (diff) |
1.3.8 to be, final beta (hopefully)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample')
-rw-r--r-- | sample/cal.rb | 16 | ||||
-rw-r--r-- | sample/goodfriday.rb | 19 |
2 files changed, 11 insertions, 24 deletions
diff --git a/sample/cal.rb b/sample/cal.rb index c65f7a70f8..cf82c6421c 100644 --- a/sample/cal.rb +++ b/sample/cal.rb @@ -1,7 +1,7 @@ #! /usr/local/bin/ruby -# cal.rb (bsd compatible version): Written by Tadayoshi Funaba 1998, 1999 -# $Id: bsdcal.rb,v 1.4 1999/03/06 02:05:59 tadf Exp $ +# cal.rb: Written by Tadayoshi Funaba 1998, 1999 +# $Id: cal.rb,v 1.5 1999/08/04 14:54:18 tadf Exp $ require 'date2' @@ -35,11 +35,11 @@ def usage exit 1 end -def cal(m, y, gs) +def cal(m, y, sg) for d in 1..31 - break if jd = Date.exist?(y, m, d, gs) + break if jd = Date.exist?(y, m, d, sg) end - fst = cur = Date.new(jd, gs) + fst = cur = Date.new(jd, sg) ti = Date::MONTHNAMES[m] ti << ' ' << y.to_s unless $yr mo = ti.center((($w + 1) * 7) - 1) << "\n" @@ -91,7 +91,7 @@ while /^-([^-].*)$/no =~ $*[0] $*.shift end $*.shift if /^--/no =~ $*[0] -usage if (gs = $tab[$cc]).nil? +usage if (sg = $tab[$cc]).nil? case $*.length when 0 td = Date.today @@ -110,10 +110,10 @@ usage unless m.nil? or (1..12) === m usage unless y >= -4712 $w = if $jd then 3 else 2 end unless $yr - print cal(m, y, gs) + print cal(m, y, sg) else print y.to_s.center(((($w + 1) * 7) - 1) * (if $jd then 2 else 3 end) + (if $jd then 2 else 4 end)), "\n\n", - zip((1..12).collect{|m| cal(m, y, gs)}), "\n" + zip((1..12).collect{|m| cal(m, y, sg)}), "\n" end diff --git a/sample/goodfriday.rb b/sample/goodfriday.rb index f0027ec5dd..cc541af3f3 100644 --- a/sample/goodfriday.rb +++ b/sample/goodfriday.rb @@ -1,25 +1,12 @@ #! /usr/local/bin/ruby # goodfriday.rb: Written by Tadayoshi Funaba 1998 -# $Id: goodfriday.rb,v 1.1 1998/03/08 09:44:44 tadf Exp $ +# $Id: goodfriday.rb,v 1.3 1999/08/04 14:54:18 tadf Exp $ require 'date2' +require 'holiday' -def easter(y) - g = (y % 19) + 1 - c = (y / 100) + 1 - x = (3 * c / 4) - 12 - z = ((8 * c + 5) / 25) - 5 - d = (5 * y / 4) - x - 10 - e = (11 * g + 20 + z - x) % 30 - e += 1 if e == 25 and g > 11 or e == 24 - n = 44 - e - n += 30 if n < 21 - n = n + 7 - ((d + n) % 7) - if n <= 31 then [y, 3, n] else [y, 4, n - 31] end -end - -es = Date.new3(*easter(Time.now.year)) +es = Date.easter(Date.today.year) [[-9*7, 'Septuagesima Sunday'], [-8*7, 'Sexagesima Sunday'], [-7*7, 'Quinquagesima Sunday (Shrove Sunday)'], |