A little calculator to get the date of Easter in various years using an algorithm from the Astronomy FAQ. [MNO] #!/bin/sh # next line restarts with tclsh \ exec tclsh $0 ${1+"$@"} # # Author: Mark Oakden http://wiki.tcl.tk/MNO # Version: 1.0 # # calculate Easter Sunday using the algorithm given at # http://www.faqs.org/faqs/astronomy/faq/part3 # # assumes Gregorian calendar # proc easterdate { year } { # # G is "golden number" # set G [expr {($year % 19) + 1}] # # H is intermediate in calculating C # set H [expr {int($year / 100)}] # # C is "century term" # set C [expr {(-1 * $H) + int($H/4) + int(8*($H+11)/25)}] # # first we need the paschal full moon. # the following is in days before april 19 with a couple of exceptions # set rawdays [expr {((11*$G)+$C) % 30}] # # exceptions if rawdays = 0 use days=1 # if rawdays = 1 and G >= 12 use days=2 # else use days=rawdays # if { $rawdays == 0 } then { set days 1 } elseif { $rawdays == 1 && $G >= 12} { set days 2 } else { set days $rawdays } # # now find the day that this falls on:- # set apr19 [clock scan "04/19/$year 12:00"] # %w is week day number Sun=0 set pfmweekdaynum [clock format [clock scan "-$days days" -base $apr19] -format "%w"] # # Easter sunday is the next Sunday _strictly_ after PFM, so # if pfmweekday is sunday, we want 7 days after pfm # if pfmweekday is monday, we want 6 days after pfm etc. # i.e. we want to take (7-pfmweekdaynum) days after pfm # set easterdate [clock scan "[expr {-($days - 7 + $pfmweekdaynum)}] days" -base $apr19] return $easterdate } for { set i 1995 } { $i <= 2015 } { incr i } { puts "Easter Sunday in $i will be on [clock format [easterdate $i] -format {%b %d}]" } ---- [PT] writes: In a strange twist of fate - the very day this was posted a colleague wished to know this date for 2004. Tcl wins the day! ---- [TFW] OK, now someone with more time on their hands than me compute the Orthodox dates. Look at http://www.assa.org.au/edm.html#OrthCalculator for a clue. ---- [Gerald Lester] Put braces around expressions just like they should be. ---- [glennj] 2008-02-08 -- removed date arithmetic using 86400 seconds per day, replaced with use of [[clock scan ... -base]] to calculate dates ---- [Category Package] | [Category Date and Time]