sample/goodfriday.rb


DEFINITIONS

This source file includes following functions.


   1  #! /usr/bin/env ruby
   2  
   3  # goodfriday.rb: Written by Tadayoshi Funaba 1998, 2000, 2002
   4  # $Id: goodfriday.rb,v 1.1 1998-03-08 18:44:44+09 tadf Exp $
   5  
   6  require 'date'
   7  
   8  def easter(y)
   9    g = (y % 19) + 1
  10    c = (y / 100) + 1
  11    x = (3 * c / 4) - 12
  12    z = ((8 * c + 5) / 25) - 5
  13    d = (5 * y / 4) - x - 10
  14    e = (11 * g + 20 + z - x) % 30
  15    e += 1 if e == 25 and g > 11 or e == 24
  16    n = 44 - e
  17    n += 30 if n < 21
  18    n = n + 7 - ((d + n) % 7)
  19    if n <= 31 then [y, 3, n] else [y, 4, n - 31] end
  20  end
  21  
  22  es = Date.new(*easter(Time.now.year))
  23  [[-9*7, 'Septuagesima Sunday'],
  24   [-8*7, 'Sexagesima Sunday'],
  25   [-7*7, 'Quinquagesima Sunday (Shrove Sunday)'],
  26   [-48,  'Shrove Monday'],
  27   [-47,  'Shrove Tuesday'],
  28   [-46,  'Ash Wednesday'],
  29   [-6*7, 'Quadragesima Sunday'],
  30   [-3*7, 'Mothering Sunday'],
  31   [-2*7, 'Passion Sunday'],
  32   [-7,   'Palm Sunday'],
  33   [-3,   'Maunday Thursday'],
  34   [-2,   'Good Friday'],
  35   [-1,   'Easter Eve'],
  36   [0,    'Easter Day'],
  37   [1,    'Easter Monday'],
  38   [7,    'Low Sunday'],
  39   [5*7,  'Rogation Sunday'],
  40   [39,   'Ascension Day (Holy Thursday)'],
  41   [42,   'Sunday after Ascension Day'],
  42   [7*7,  'Pentecost (Whitsunday)'],
  43   [50,   'Whitmonday'],
  44   [8*7,  'Trinity Sunday'],
  45   [60,   'Corpus Christi (Thursday after Trinity)']].
  46  each do |xs|
  47    puts((es + xs.shift).to_s + '  ' + xs.shift)
  48  end