Author Topic: Easter date...  (Read 6419 times)

0 Members and 1 Guest are viewing this topic.

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
Easter date...
« on: August 03, 2019, 03:45:02 am »
When you work on the calendar, it may be useful to know the date of Easter ...
This little program gives you the date of Easter Day.


Code: Text: [Select]
  1. Question: INPUT "Year you want to know the day of Easter"; Q$: IF Q$ = "" THEN END
  2. PQA = VAL(Q$): IF PQA < 1582 THEN BEEP: GOTO Question
  3. GOSUB PAQUES
  4. PRINT "Easter date ---> month : "; PQM; "  day : "; PQJ; "  year: "; PQA: GOTO Question
  5.  
  6. PAQUES: PQM = INT(PQA / 100): PQ1 = PQA - PQM * 100: PQJ = INT(((PQA / 19 - INT(PQA / 19)) + .001) * 19)
  7. PQ2 = INT(PQM / 4): PQ3 = INT(((PQM / 4) - PQ2 + .001) * 4): PQ4 = INT((8 + PQM) / 25)
  8. PQ5 = INT((1 + PQM - PQ4 + .001) / 3): PQ4 = (15 + 19 * PQJ + PQM - PQ2 - PQ5 + .001) / 30: PQ4 = PQ4 - INT(PQ4)
  9. PQ4 = INT(PQ4 * 30): PQ5 = INT(PQ1 / 4): PQ6 = ((PQ1 / 4) - PQ5) * 4
  10. PQ7 = (32 + 2 * PQ3 + 2 * PQ5 - PQ4 - PQ6 + .001) / 7: PQ7 = (PQ7 - INT(PQ7)) * 7: PQ6 = (PQJ + 11 * PQ4 + 22 * PQ7) / 451
  11. PQ6 = INT(PQ6): PQ2 = (114 + PQ4 + PQ7 - 7 * PQ6) / 31: PQM = INT(PQ2): PQJ = INT((PQ2 - PQM + .001) * 31 + 1)
  12. RETURN
  13.  
Why not yes ?

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Easter date...
« Reply #1 on: August 03, 2019, 07:16:25 pm »
That is so cool thanks for posting it!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Easter date...
« Reply #2 on: August 03, 2019, 08:07:53 pm »
nice program!
Thanks to share!

here the same code packed in a SUB to be used anywhere  and returning value by parameters
if you got two -1 back  you get an inner error for invalid parameter Year

and a little demo of the SUB

Code: QB64: [Select]
  1.  DEFINT A
  2. PRINT SPACE$(15) + "YEAR", "MOUNTH", "DAY"
  3. FOR A = 1 TO 10
  4.     AY = INT(RND * 600) + 1541
  5.     Easter_Day AY, AM, AD
  6.     PRINT STRING$(A, "-") + ">", AY, AM, AD
  7. ' testing invalid parameter
  8. AY = 1400: AM = 0: AD = 0
  9. Easter_Day AY, AM, AD
  10. IF AM = -1 AND AD = -1 THEN PRINT "Error: invalid value of input parameter" ELSE PRINT STRING$(A, "~") + ">", AY, AM, AD
  11. 'testing valid parameter
  12. AY = 1900: AM = 0: AD = 0
  13. Easter_Day AY, AM, AD
  14. IF AM = -1 AND AD = -1 THEN PRINT "Error: invalid value of input parameter" ELSE PRINT STRING$(A, "~") + ">", AY, AM, AD
  15.  
  16.  
  17. SUB Easter_Day (Year AS INTEGER, Mounth AS INTEGER, Day AS INTEGER)
  18.     DEFSNG P
  19.     IF Year < 1542 THEN
  20.         Mounth = -1
  21.         Day = -1
  22.         EXIT SUB
  23.     END IF
  24.     PQA = Year
  25.     PQM = INT(PQA / 100): PQ1 = PQA - PQM * 100: PQJ = INT(((PQA / 19 - INT(PQA / 19)) + .001) * 19)
  26.     PQ2 = INT(PQM / 4): PQ3 = INT(((PQM / 4) - PQ2 + .001) * 4): PQ4 = INT((8 + PQM) / 25)
  27.     PQ5 = INT((1 + PQM - PQ4 + .001) / 3): PQ4 = (15 + 19 * PQJ + PQM - PQ2 - PQ5 + .001) / 30: PQ4 = PQ4 - INT(PQ4)
  28.     PQ4 = INT(PQ4 * 30): PQ5 = INT(PQ1 / 4): PQ6 = ((PQ1 / 4) - PQ5) * 4
  29.     PQ7 = (32 + 2 * PQ3 + 2 * PQ5 - PQ4 - PQ6 + .001) / 7: PQ7 = (PQ7 - INT(PQ7)) * 7: PQ6 = (PQJ + 11 * PQ4 + 22 * PQ7) / 451
  30.     PQ6 = INT(PQ6): PQ2 = (114 + PQ4 + PQ7 - 7 * PQ6) / 31: PQM = INT(PQ2): PQJ = INT((PQ2 - PQM + .001) * 31 + 1)
  31.     Mounth = PQM
  32.     Day = PQJ
  33.  
  34.  
  35.  
  36.  
Programming isn't difficult, only it's  consuming time and coffee

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
Re: Easter date...
« Reply #3 on: August 04, 2019, 04:19:51 am »
TempodiBasic: Ok for the "sub way" : )

For information: the formula used in this program was developed by monks in the Middle Ages !
Why not yes ?

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Easter date...
« Reply #4 on: August 04, 2019, 12:48:23 pm »
Yes
IMHO Gregorian calendar...see here more info https://en.wikipedia.org/wiki/Gregorian_calendar

sorry for the SUB way, but I have imagined your fine and clear code in a portable version without a need to stand in main .
Thanks again to share
Programming isn't difficult, only it's  consuming time and coffee

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Easter date...
« Reply #5 on: August 05, 2019, 07:10:45 pm »
A piece of useless trivia.... I was born on Easter Sunday... That's it. Nothing else... Continue chatting... Sorry to disturb...

J
Logic is the beginning of wisdom.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Easter date...
« Reply #6 on: August 05, 2019, 07:24:40 pm »
@johnno56

so you're beat only from who is born on 29 February!
Programming isn't difficult, only it's  consuming time and coffee

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Easter date...
« Reply #7 on: August 06, 2019, 01:24:08 am »
For those born on Feb 29 only have to wait 4 years for their birthday to fall on the same day...
Not so with mine. In my lifetime, my birthday and Easter Sunday will only occur 3 times. 1956. 2018 and 2029.
There is an 'extremely' small chance for a 4th time if I make it to 2040....

J
Logic is the beginning of wisdom.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Easter date...
« Reply #8 on: August 06, 2019, 01:34:25 am »
LOL awesome Johno! I don't remember if I posted yet, but my birthday is February 29. :)

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Easter date...
« Reply #9 on: August 06, 2019, 02:14:29 am »
Cool. Would that mean that your diver's licence show your age as 5 (if you were 21)?
Logic is the beginning of wisdom.

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
Re: Easter date...
« Reply #10 on: August 06, 2019, 04:41:28 am »
Cool. Would that mean that your diver's licence show your age as 5 (if you were 21)?

... diver ou driver licence ?
Why not yes ?

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Easter date...
« Reply #11 on: August 06, 2019, 04:42:45 am »
@johnno56

it is interesting the combination of your born dat and Easter (Sunday)....
but if I was born on 29 (not 28 a mystype) February of 1990 and it was Monday how much is the combination of these two events?
We must use the  algorithm of SierraKen!

« Last Edit: August 06, 2019, 08:58:03 am by TempodiBasic »
Programming isn't difficult, only it's  consuming time and coffee

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
Re: Easter date...
« Reply #12 on: August 06, 2019, 05:17:09 am »
@johnno56

it is interesting the combination of your born dat and Easter (Sunday)....
but if I was born on 28 February of 1990 and it was Monday how much is the combination of these two events?
We must use the  algorithm of SierraKen!
Combination between "28 february" and "monday" or "28 february" and Easter ?
Note: Easter can not take place before March 21st
Why not yes ?

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Easter date...
« Reply #13 on: August 06, 2019, 08:57:12 am »
@euclide
Quote
"29 february" and "monday"
Programming isn't difficult, only it's  consuming time and coffee

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
Re: Easter date...
« Reply #14 on: August 06, 2019, 10:05:21 am »

 2/ 29/ 1616  Monday
 2/ 29/ 1644  Monday
 2/ 29/ 1672  Monday
 2/ 29/ 1712  Monday
 2/ 29/ 1740  Monday
 2/ 29/ 1768  Monday
 2/ 29/ 1796  Monday
 2/ 29/ 1808  Monday
 2/ 29/ 1836  Monday
 2/ 29/ 1864  Monday
 2/ 29/ 1892  Monday
 2/ 29/ 1904  Monday
 2/ 29/ 1932  Monday
2/ 29/ 1960  Monday
2/ 29/ 1988  Monday
 2/ 29/ 2016  Monday
 2/ 29/ 2044  Monday
 2/ 29/ 2072  Monday


28 February of 1990 is "Wednesday"
« Last Edit: August 06, 2019, 10:10:01 am by euklides »
Why not yes ?