*>>SOURCE FORMAT IS FIXED *> *************************************************************** *> Author: Brian Tiffin *> Date: 17-Nov-2008 *> Purpose: Display Easter Day for any given year, 1580 - 2050 *> Tectonics: cobc -x easter.cob *> ./easter [year] *> *************************************************************** identification division. program-id. easter. data division. working-storage section. 01 a picture 9(8) usage comp-x. 01 b picture 9(8). 01 c picture 9(8). 01 d picture 9(8). 01 z picture 9(8). *> Why z? COBOL has pi for pi and e for e 01 f picture 9(8). 01 g picture 9(8). 01 h picture 9(8). 01 i picture 9(8). 01 j picture 9(8). 01 year picture 9(4). 01 mo picture 9(2). 01 da picture 9(2). 01 args picture x(80). *> *************************************************************** procedure division. accept args from command-line end-accept if args not equal spaces move args to year else display "Year: " with no advancing end-display accept year end-accept end-if compute a = function mod(year 19) end-compute divide year by 100 giving b remainder c end-divide divide b by 4 giving d remainder z end-divide compute f = (b + 8) / 25 end-compute compute g = (b - f + 1) / 3 end-compute compute h = (19 * a) + b - d - g + 15 end-compute compute h = function mod(h 30) end-compute divide c by 4 giving i remainder j end-divide compute c = (z + i) * 2 + 32 - h - j end-compute compute c = function mod(c 7) end-compute compute b = (a + (11 * h) + (22 * c)) / 451 end-compute compute a = h + c - (7 * b) + 114 end-compute compute da = function mod(a 31) + 1 end-compute divide a by 31 giving mo end-divide display "yyyy/mm/dd: " year "/" mo "/" da end-display goback. *> *************************************************************** *> Snagged from a REBOL script, easter-day.r by Didier Cadieu *> http://www.rebol.org/view-script.r?script=easter-day.r *> *> easter-day: func [ *> {Compute the easter date for the wanted year.} *> year [integer!] {Year for whitch you want the easter date} *> /local a b c d z f g h i k *> ] [ *> a: year // 19 *> b: to integer! year / 100 *> c: year // 100 *> d: to integer! b / 4 *> z: b // 4 *> f: to integer! b + 8 / 25 *> g: to integer! b - f + 1 / 3 *> h: 19 * a + b - d - g + 15 // 30 *> i: to integer! c / 4 *> k: c // 4 *> c: z + i * 2 + 32 - h - k // 7 *> b: to integer! a + (11 * h) + (22 * c) / 451 *> a: h + c - (7 * b) + 114 *> to date! reduce [ *> a // 31 + 1 *> to integer! a / 31 *> year *> ] *> ] end program easter.