Impressive work Rick!
Thank you.
Pierre
X
-
See http://www.powerbasic.com/support/pb...ad.php?t=53988
for a collection of functions related to date and time.
Rick Kelly
Leave a comment:
-
-
Hi Brian,
Try...
Code:LOCAL l AS LONG
Last edited by Pierre Bellisle; 27 Apr 2021, 11:47 PM.
Leave a comment:
-
-
Can anyone tell me why this code crashes when the year 2016 is selected?
2014, 2015 and 2017 are okay.
2012 and 2020 are okay.
Leave a comment:
-
-
Easter Sunday
This is a FWIW program.
How the date of Easter Sunday is calculated seemed to me to be something of art on the order of magic. I could picture someone listening to "Age of Aquarius" whilst performing the calculations. Paraphrasing Arthur C. Clarke: Any sufficiently advanced algorithm is indistinguishable from magic.
As it happens calculating the date of Easter Sunday, for the western world anyway, is fairly easy. Dates occuring before the adoption of the Gregorian calendar are likely to be way off.
Code:'Computing the Date of Easter 'In the Gregorian calendar, the date of Easter is defined to occur on the Sunday following the ecclesiastical Full Moon that 'falls on or next after March 21. This should not be confused with the popular notion that Easter is the first Sunday after 'the first Full Moon following the vernal equinox. In the first place, the vernal equinox does not necessarily occur on 'March 21. In addition, the ecclesiastical Full Moon is not the astronomical Full Moon -- it is based on tables that do not 'take into account the full complexity of lunar motion. As a result, the date of an ecclesiastical Full Moon may differ from 'that of the true Full Moon. However, the Gregorian system of leap years and lunar tables does prevent progressive departure 'of the tabulated data from the astronomical phenomena. ' 'The ecclesiastical Full Moon is defined as the fourteenth day of a tabular lunation, where day 1 corresponds to the 'ecclesiastical New Moon. The tables are based on the Metonic cycle, in which 235 mean synodic months occur in 6939.688 'days. Since nineteen Gregorian years is 6939.6075 days, the dates of Moon phases in a given year will recur on nearly the 'same dates nineteen years laters. To prevent the 0.08 day difference between the cycles from accumulating, the tables 'incorporate adjustments to synchronize the system over longer periods of time. Additional complications arise because the 'tabular lunations are of 29 or 30 integral days. The entire system comprises a period of 5700000 years of 2081882250 days, 'which is equated to 70499183 lunations. After this period, the dates of Easter repeat themselves. 'This algorithm is the work of J.M. Oudin (1940) #COMPILE EXE #DIM ALL FUNCTION PBMAIN () AS LONG LOCAL y AS DWORD LOCAL c AS DWORD LOCAL n AS DWORD LOCAL k AS DWORD LOCAL i AS DWORD LOCAL j AS DWORD LOCAL l AS DWORD LOCAL m AS DWORD LOCAL d AS DWORD LOCAL x AS DWORD LOCAL month() AS STRING LOCAL year AS STRING DATA January, February, March, April, May, June, July, August, September, October, November, December DIM month(DATACOUNT) FOR x = 1 TO DATACOUNT month(x) = READ$(x) NEXT x year = INPUTBOX$("Enter Year","Easter Sunday Calculator", "2009") y = VAL(year) IF y = 0 THEN y = 2009 c = INT(y / 100) n = y - 19 * INT( y / 19 ) k = INT(( c - 17 ) / 25) i = c - INT(c / 4) - INT(( c - k ) / 3) + 19 * n + 15 i = i - 30 * INT( i / 30 ) i = i - INT( i / 28 ) * INT(( 1 - ( i / 28 ) * ( 29 / ( i + 1 ) )* ( ( 21 - n ) / 11 ) )) j = y + INT(y / 4) + i + 2 - c + INT(c / 4) j = j - 7 * INT( j / 7 ) l = i - j m = 3 + INT(( l + 40 ) / 44) d = l + 28 - 31 * INT( m / 4 ) ? month(m) + " " + FORMAT$(d),,"Easter Sunday " + FORMAT$(y) + ":" END FUNCTION
Tags: None
-
Leave a comment: