LB Booster
« Easter »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:31am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Easter  (Read 351 times)
Jack Kelly
Full Member
ImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 106
xx Easter
« Thread started on: Sep 17th, 2016, 1:55pm »

I found this snippet in the Liberty BASIC Community Wiki, posted in the Shared Code section by HarmonV. I was impressed. You know how I like calendar functions.

Code:
' Easter date Calculation -- function definition by HarmonV,  February 2007
print "The date of Easter for any year from 1583 to 4099."
print ""
[begin] 
input "Enter year: "; yyyy
yyyy=abs(int(yyyy))
if yyyy=0 then [finish]
Easter$ = Easter$(yyyy)
if Easter$<>"" then
    print Easter$
else
    print "Invalid year"
end if
goto [begin]
 
[finish]
print "Done."
end
 
function Easter$(yyyy)
    if yyyy<1583 or yyyy>4099 then Easter$="": exit function
    gn = yyyy mod 19 + 1    ' Golden Number
    c = int(yyyy/100)+1     ' Century
    JE = (11*(gn-1)) mod 30 ' Julian Epact #
    S = int(3*c/4)          ' Solar Equation (3 non-leap days every 4 centuries)
    L = int((8*c+5)/25)     ' Lunar Equation (8 days every 25 centuries)
    GE = JE - S + L + 8     ' Gregorian Epact #
    if GE<1 then GE = GE + 30*(1+int(abs(GE)/30))
    GE = GE mod 30
' efm = Ecclesiastical full moon (22=Mar 22nd, 32=Apr 1st, etc)
    if GE<24 then efm = 44-GE
    if GE>23 then efm = 74-GE
    if (GE=24) or (GE=25 and gn>11) then efm = efm - 1
 
    wd = (efm + 2 + yyyy + int(yyyy/4) - int(yyyy/100) + int(yyyy/400) ) mod 7
    ed = efm + 7 - wd    ' Easter Day = first Sunday after EFM
    mm = 3+int(ed/32): mm$=str$(mm): if len(mm$)=1 then mm$="0"+mm$
    dd = ed - 31*int(mm/4): dd$=str$(dd): if len(dd$)=1 then dd$="0"+dd$
    Easter$ = str$(yyyy)+mm$+dd$
end function
 


I made myself a page there and posted some of my recent programs. The "organizers" went to a great deal of effort making the wiki many years ago, but it doesn't appear to be getting much use lately.

http://basic.wikispaces.com/JackKelly6
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Easter
« Reply #1 on: Sep 17th, 2016, 3:44pm »

on Sep 17th, 2016, 1:55pm, Jack Kelly wrote:
I found this snippet in the Liberty BASIC Community Wiki, posted in the Shared Code section by HarmonV. I was impressed.

Indeed, calculating the date of Easter is challenging. Another difficult calendar-related problem is calculating sunrise and sunset times accurately, especially for latitudes where they don't happen at all for some of the year! I've got some BBC BASIC code to do it but I've not tried translating it to Liberty BASIC.

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls