vytvor v pythonu program pro vypocet velikonocnich nedeli dle juliánského kalendare.
k vypoctum -
Calculation of Easter Sunday in the Julian calendar
By definition, Easter Sunday is the first Sunday after an ecclesiastical (Paschal) full moon (i.e. it’s the first full moon after 20 March). So, if a full moon occurs the very next day (Saturday the 21st), then Easter could theoretically be celebrated as early as the 22nd of March. These ecclessiastical full moons are derived from an ancient calculation that gives an approximation of the phases of the Moon. Over a nineteen year span, these lunar phases all roughly settle into the same calendar days. This cycle is called the Metonic cycle (also, the lunar cycle) and the year’s location in the order of this cycle gives us the “Golden Number”. In the following calculations, only integers are counted, the '%' character indicates that the remainder of the division is the only part to be used.
Calculation formula: golden_number = 1 + year % 19
All lunar cycles are about 29.5 days in length (a lunation, or a synodic month), and these lunar cycles fit twelve times into a year (29.5 x 12 = 354), which comes up 11 days short of the solar year. Since decimal numbers weren’t used in the Middle Ages, lunar lengths alternated between 29-day (empty month) and 30-day (full month) lengths. With the alternation between six empty and six full months, the year’s total comes out to the same amount of 354 days (6 × 29 + 6 × 30). An epact was used to fix this deficiency. Epacts measure how old the phase of the moon is from a specific date (almost always 22 March, the ecclesiastical start of spring) and average out to 11 days. Now, looking at the calculations below, we need to assume all months are 30 days in length. Until one of the epacts exceeds 30, subtract 30 and continue as usual in the next month. What you’d find after doing this for 19 years is that the difference in the age of the moon results in 209 days (19 × 11 = 209). In order to get this number divisible by 30, once every 19 years an extra day is inserted (Latin: saltus lunae) which brings it all back into alignment. Now, the age of the moon has come full circle, and both solar and lunar years can start the cycle anew.
Calculation formula: epact = (11 × (golden_number - 1)) % 30
or, expressed differently: epact = 11 × (year % 19)) % 30
The above is a calculation for the Alexandrian epact, which expresses the age of the lunation on 22 March. This epact was used by the computists Dionysius and Beda the Venerable (Quae in circulo decemnovennali adnotatae sunt epactae, lunam quota si in XI cal. Apriles). Now, we can uniquely assign an epact to each Golden Number and make the following table:
Golden number 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Epact 0 11 22 3 14 25 6 17 28 9 20 1 12 23 4 15 26 7 18
The epacts were originally displayed as Roman numerals, and because they didn’t have a character for zero, they used either an asterisk or wrote ‘null’ (nullae). Notice how the epact grows by eleven (0 + 11 = 11, 11 + 11 = 22, etc), but when it breaks 30, we subtract 30 and carry on (22 + 11 = 33 - 30 = 3). It’s not until we reach the end of the cycle that twelve is added, (18 + 12 = 30), which allows us to subtract 30 and start afresh. It is this way that the Alexandrian epacte was able to get these nineteen values with precision.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
If we know the Alexandrian epact, it is no longer a problem to determine the ecclesiastical (Paschal) full moon, because of how it uses 22 March as the basis of the calculation. This makes the calendar date easy to calculate:
for epact 0 - 15: full_moon_date = 36 - epact
for epact 16 - 29 (actually only 17 - 28): full_moon_date = 66 - epact
If the result is a number greater than 31, then the ecclesiastical full moon (Paschal full moon) won’t begin until April. To solve this, we can subtract 31 from the result to get the April date. We can take this further by extending the previous table to include dates of the calculated Paschal full moon:
Golden number 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Epact 0 11 22 3 14 25 6 17 28 9 20 1 12 23 4 15 26 7 18
Date Apr 5 Mar 25 Apr 13 Apr 2 Mar 22 Apr 10 Mar 30 Apr 18 Apr 7 Mar 27 Apr 15 Apr 4 Mar 24 Apr 12 Apr 1 Mar 21 Apr 9 Mar 29 Apr 17
As mentioned above, the earliest possible date for the ecclesiastical full moon is 21 March (Golden Number 16) and if it’s a Saturday, that would make the next day Easter Sunday. And while that makes the earliest possible Easter date 22 March, the last possible date is 25 April. This is a full lunation away from the ecclesiastical start of spring plus 7 more days to the next Sunday if the full moon happens to occur on a Sunday. Because the ecclesiastical full moon occurs between 21 March and 18 April, there are only 29 possible dates, of which 19 days are occupied, because the Alexandrian epact only allows 19 of them to be made possible before the cycle refreshes. All that remains now is to determine how many days of the week to each full moon, in order to determine when the following (Easter) Sunday will fall. The following formula can be used in the Julian calendar to accomplish this (as always: only count whole numbers!):
day_of_week = (year + year / 4 + full_day) % 7
The number 0 is Sunday, 1 is Monday, and so on until 6, which is Saturday.
The calendar date of Easter Sunday in the Julian calendar is then easy to obtain:
Easter_Sunday = full_moon_date + (7 - day_of_week)
if we get a number greater than 31, it’s an April date - in this case, it is then necessary to subtract 31; if not, it’s a March date
The above calculations only apply to the old Julian calendar where calculating Easter Sunday is much easier than in our current Gregorian calendar! The end result is the calendar date of Easter Sunday in the Julian calendar.
budou se používat pouze algoritmy pro vypocet velikonocnich nedeli dle juliánského kalendare. juliansky kalendar ma 365 dnu a každý ctvrty rok 366 dnu. nesmí se používat zadne algoritmy pro vypocet velikonocnich nedeli z gregoriánského kalendare. rozsah roku pro vypocet bude 400-6000 dle bezne známého letopoctu. pak bude program umoznovat vytvaret dve linie kalendaru, které se od sebe lisi tim, ze se zaprvé na vstupu v libovolny rok zada počet dnu (maximalne 40), který bude mit prvni z tech kalendaru v roce méně (dny se budou odstranovat na konci roku, to znamena, ze když se odstrani deset dnu, bude nasledujici den po 20.prosinci 31.prosinec, dny v tydnu ale nejsou preruseny, takze napriklad po pondeli je vzdy utery.), ale pouze ten jeden rok, zadruhe ze se na vstupu opet pro prvni kalendar zada libovolny sty rok, od kterého se budou povazovat nasledujici tri ste roky za roky s jednim dnem méně oproti druhemu kalendari a tak to bude pokracovat dal v rozmezích 400 let - prvni sty rok stejny, další tri ste roky o jeden den méně oproti druhemu kalendari (tedy napriklad zadali se rok 400, rok 400 ma 366 dnu, rok 500, 600 a 700 ma 365 dnu a tak dale). program pak vypocita kolik tydnu je rozdil mezi velikonocnimi nedelemi, vcetne rozdilu 0 tyden, pokud takova moznost nastane, v jednotlivých rocích od 400 po 6000 a tyto hodnoty označené roky zapise do textového souboru do stejne slozky, kde bude umisten python skript. dale bude v programu moznost zadat rozsah roku, za kterézto obdobi bude spocitan soucet odlisnosti v jednom roce. nezapomen, ze kalendare se lisi, takze pro porovnani se musi velikonoce z prvniho kalendare porovnat s druhym tak, ze se prevede prvni kalendar velikonoce do druheho kalendare a pak se teprve porovnaji s velikonocemi z druheho kalemdare. do textoveho souboru zapis velikonoce z prvniho kalendare, do zavorky, jaky datum to je v druhem kalendari, pak teprve velikonoce z druheho kalendare. a pak rozdil v tydnech.
to znamena, pokud nastavim v prvnim kalendari rok 1582 10 dnu mene a dale v prvnim kalendari od roku 1600 zmeny po 400 letech tri dny, pak se to bude chovat jako gregoriansky kalendar. nechtel jsem uzivani gregorianskych algoritmu, protoze se muzou menit podminky ruzne. ale pouze v prvnim kalendari. v druhem kalendari zustava algoritmus juliansky.
toto je popis, jak se pocitaji zmeny, kdyby slo o priklad zmeny v prvnim kalendari, jak bylo uvedeno pro priklad vyse.
Calculation of Easter Sunday in the Gregorian calendar
For a better understanding of this text, it is recommended to first go over the calculation procedure for Easter Sunday in the Julian calendar!
In principle, the way you go about calculating the date for Easter Sunday in the Gregorian calendar is the same as you would calculate it in the Julian calendar. Using the epact, we find the first ecclesiastical (paschal) full moon, and then we find the first Sunday that follows it: this will give us Easter Sunday. In the following calculations, only whole numbers will be used. The '%' character (modulo) indicates that the remainder of the division is the only part to be used. What follows is the original calculation for the Gregorian epact, as written by Christoph Clavius (see Commission for the Reform of the Calendar) ROMANI CALENDARII AND GREGORIO XIII. P.M. RESTAURANTS Explicatio; this book uses tables instead of formulas to help you obtain the necessary values. Now, first we need to find the Golden Number for the given year.
Calculation formula: golden_number = 1 + year % 19
We will now calculate the Julian epact. The constant 11 needs to be added to balance the year, a correction which was discovered by observing how new moons actually appeared during the time of the Gregorian reform. It merely causes a shift of three days, as compared to the calculations in the old Julian calendar, but the fact is, these old calculations differed from the astronomical reality of the time by as many as four days. According to the old tables, the first new moon of the year for Golden Number 1 was supposed to occur on 23 January (see the chronological table). After instituting the new reform, 10 days had to be removed, so they chose to postpone its removal until the 2nd of February, that way the new moon that preceded it in the calendar would be on the 3rd of January. Aloysius Lilius then adjusted the cyclic new moon for Gregorian epact 1 back three days (0 January ≡ 31 December). The Julian epact itself indicates this three-day correction of the new moon in the Julian calendar. More on this can be found on the page Comparison of Julian and Gregorian cyclic calculations.
Calculation formula: Julian_epact = (11 × (golden_number - 1) + 11) % 30
which can be simplified to Julian_epact = 11 × golden_number % 30
or to express it another way: Julian_epact = (11 × (year % 19) + 11) % 30
From this, we can easily calculate the following table, where each Golden Number is uniquely assigned a Julian epact:
Golden number 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Julian epact 11 22 3 14 25 6 17 28 9 20 1 12 23 4 15 26 7 18 29
Up to this point, the procedure has been similar to the Julian calendar, but now it’s necessary to correct (align) the Julian epact in order to get the final Gregorian epact. The first thing we need to do is calculate the century in which the year is given. In this calculation, when we say “century” we mean something slightly different than the current understanding of a century. For this calculation, each century will begin with a “centenary year” (years that end with two zeros; e.g. 1900, 2000, 2100) and end with “99”. This flies in the face of the common calculation of a century, which begins at one, not zero. For example, the 21st century contains the years 2001 and 2100 inclusive, but for the following calculations, we’ll treat the 21st century as the years 2000 to 2099 inclusive.
Calculation formula: century = (year / 100) + 1
In the Gregorian calendar, centenary years are only considered leap years if they’re divisible by 400. So, in a 400-year cycle, three leap days will be dropped, as opposed to in the Julian calendar. The epact also needs to be reduced by these days, through what is known as the solar equalisation (aequatio solaris). This correction is performed for non-century years (i.e. 1700, 1800, 1900, 2100, 2200, 2300, 2500, etc):
Calculation formula: solar_correction = 3 × (century - 16) / 4
For the next century, we’ll then take the values given in the table, and because this correction is done through subtraction, you’ll see that they are listed as negative values. The negative value grows gradually as the leap days in the centenary years are omitted. Since the year of the transition from the 20th to the 21st century (i.e. the year 2000) was a leap year in the Gregorian calendar (just as it is in the Julian calendar), the value did not need to be changed.
Century
years 16th
1583-99 17th
1600-99 18th
1700-99 19th
1800-99 20th
1900-99 21th
2000-99 22th
2100-99 23th
2200-99 24th
2300-99 25th
2400-99
Solar
correction 0 0 -1 -2 -3 -3 -4 -5 -6 -6
Not even a 19-year lunar cycle is entirely accurate, because after 19 years, lunar phases fall back 1.5 hours earlier, causing an error of one day that will occur after 300 years. The calendar commission eventually decided that in a cycle of 2,500 years, a lunar correction (aequatio lunaris) would be applied eight times (i.e. on average, once every 312.5 years). This correction would only occur on centenary years as well. According to it, the repair was to be performed every 300, and those years would be 1800, 2100, 2400, 2700, 3000, 3300, 3600, 3900. However, not in 4200, but in 4300 (which would be after 400 years). After all of that time, the 2500-year cycle would thenrepeat itself.
Calculation formula: lunar_correction = 8 × (century - 15) / 25
For the next century we get the following values given in the table:
Century
years 16th
1583-99 17th
1600-99 18th
1700-99 19th
1800-99 20th
1900-99 21th
2000-99 22th
2100-99 23th
2200-99 24th
2300-99 25th
2400-99
Lunar
correction 0 0 0 1 1 1 2 2 2 3
Both corrections performed on separate centennial years can be displayed in a table clearly (corr.: correction). Also, don't forget about the 'irregularity' of the lunar correction, because after 3900 the repair will occur after 400 years, not the usual 300 years. Since this is repeated in cycles of 2500 years, it will occur next in 6400.
year solar
corr. lunar
corr.
1600
1700 -1
1800 -1 +1
1900 -1
2000
2100 -1 +1
2200 -1
2300 -1
2400 +1
2500 -1
2600 -1
2700 -1 +1
2800
2900 -1
3000 -1 +1
3100 -1
year solar
corr. lunar
corr.
3200
3300 -1 +1
3400 -1
3500 -1
3600 +1
3700 -1
3800 -1
3900 -1 +1
4000
4100 -1
4200 -1
4300 -1 +1
4400
4500 -1
4600 -1 +1
4700 -1
year solar
corr. lunar
corr.
4800
4900 -1 +1
5000 -1
5100 -1
5200 +1
5300 -1
5400 -1
5500 -1 +1
5600
5700 -1
5800 -1 +1
5900 -1
6000
6100 -1 +1
6200 -1
6300 -1
year solar
corr. lunar
corr.
6400 +1
6500 -1
6600 -1
6700 -1
6800 +1
6900 -1
7000 -1
7100 -1 +1
7200
7300 -1
7400 -1 +1
7500 -1
7600
7700 -1 +1
7800 -1
7900 -1
year solar
corr. lunar
corr.
8000 +1
8100 -1
8200 -1
8300 -1 +1
8400
8500 -1
8600 -1 +1
8700 -1
8800
8900 -1 +1
9000 -1
9100 -1
9200
9300 -1 +1
9400 -1
9500 -1
The last correction necessary is the deduction of the ten days omitted during the Gregorian calendar reform. From this, we obtain the resulting Gregorian epact.
Calculation formula: Gregorian_epact = Julian_epact - 10 - solar_correction + lunar_correction
if the result of the line is less than 0, add 30, or if the result is greater than 29, subtract 30.
Below is a simple table of the result of all corrections of the Julian epact for the Gregorian calendar for the coming centuries. Sometimes the corrections cancel each other out and the resulting correction ends up looking the same (e.g. during the transition from the 21st to the 22nd century, both the solar and lunar corrections will change, but since they cancel each other out, the correction remains unchanged overall).
Century
years 16th
1583-99 17th
1600-99 18th
1700-99 19th
1800-99 20th
1900-99 21th
2000-99 22th
2100-99 23th
2200-99 24th
2300-99 25th
2400-99
resulting
correction -10 -10 -11 -11 -12 -12 -12 -13 -14 -13
Different centuries have their own 19-year series epact. However, the essence of them remain the same as for the Alexandrian epacts. In these, the value increases after each year of the nineteen-year Golden Number circle after 11, until it reaches the end of the cycle and it sees an increase of 12 (i.e. 11 x 8 + 12). This is due to the fact that each cycle is interrupted when moving to another century, because they have their own unique corrections. For example, the year 1862 has the Golden Number 1 and belongs to the 19th century. The Gregorian epact of 1862 is 0. The following year with the Golden Number 1 is the year 1881, but because it also belongs to the 19th century, it has the same epact 0. However, in the year 1900, another year with the Golden Number 1, is considered part of the 20th century (recall earlier how we had to change our understanding of centuries to make them start with 0 for these calculations). In this year there is another correction of the Julian epact necessary and therefore the resulting Gregorian epact is 29. For a list of all possible epact series, see the page All possible Gregorian epact series, but for now, you can see a table below that displays an epact series for recent and upcoming centuries. In the 20th, 21st and 22nd centuries, the series of epacts do not change, so it could be said that in terms of the series of Gregorian epacts, we live in peaceful times.
Golden
number julian
epact 16th
1583-99 17th
1600-99 18th
1700-99 19th
1800-99 20th
1900-99 21th
2000-99 22th
2100-99 23th
2200-99 24th
2300-99 25th
2400-99
1 11 1 1 0 0 29 29 29 28 27 28
2 22 12 12 11 11 10 10 10 9 8 9
3 3 23 23 22 22 21 21 21 20 19 20
4 14 4 4 3 3 2 2 2 1 0 1
5 25 15 15 14 14 13 13 13 12 11 12
6 6 26 26 25 25 24 24 24 23 22 23
7 17 7 7 6 6 5 5 5 4 3 4
8 28 18 18 17 17 16 16 16 15 14 15
9 9 29 29 28 28 27 27 27 26 25 26
10 20 10 10 9 9 8 8 8 7 6 7
11 1 21 21 20 20 19 19 19 18 17 18
12 12 2 2 1 1 0 0 0 29 28 29
13 23 13 13 12 12 11 11 11 10 9 10
14 4 24 24 23 23 22 22 22 21 20 21
15 15 5 5 4 4 3 3 3 2 1 2
16 26 16 16 15 15 14 14 14 13 12 13
17 7 27 27 26 26 25 25 25 24 23 24
18 18 8 8 7 7 6 6 6 5 4 5
19 29 19 19 18 18 17 17 17 16 15 16
The Gregorian epact can take values from 0 to 29, as can the Coptic epact from the calculation of Easter Sunday in the Julian calendar. In some sources, 30 is used instead of 0, but an asterisk was originally used, while other epact numbers were written in Roman numerals. However, only 19 different values are used in a given century. There’s a problem with a total of 30 values in the Gregorian epact, because as we know from the old Julian calculation, an ecclesiastical full moon can occur between 21 March and 18 April, which is only a 29 day range. In the calculation for the Julian calendar, 19 possible Alexandrian epacts were easily divisible between those 29 days, but for 30 Gregorian epacts it is not as simple. This range of 29 days had to be maintained in the new Gregorian calendar according to the wishes of the church. An earlier date was out of the question, as it would be before the church's beginning of spring. And if the last date was extended to 19 April 19, there could be a case where Easter Sunday is 26 April. Fearing that many people would not adopt the new calendar for this reason, this option was ultimately rejected. In addition, the church demanded that the latest date of Easter Sunday not appear twice in one nineteen-year cycle of the Golden Number.
Therefore, epact 25 was finally selected, which was assigned two possible calendar dates for the ecclesiastical full moon as the 17th or 18th of April. You can use the following rule to determine which date to use: if the Golden number is greater than or equal to 12, the date of 17 April 17 is selected, otherwise 18 April is selected. This will prevent a repeat of the latest Easter Sunday in a nineteen-year cycle. If necessary, on this website an epact with an earlier date of the cyclic full moon (i.e. a Golden Number greater than 11) will be written in bold (such as 25).
Each epact value can be uniquely assigned an ecclesiastical full moon date, except for epact 25, which can be assigned two calendar dates:
Conversion table
Gregorian
epact Ecclesiastical
full moon
23 March 21
22 March 22
21 March 23
20 March 24
19 March 25
18 March 26
17 March 27
16 March 28
15 March 29
14 March 30
13 March 31
12 April 1
11 April 2
10 April 3
9 April 4
8 April 5
7 April 6
6 April 7
5 April 8
4 April 9
3 April 10
2 April 11
1 April 12
0 April 13
29 April 14
28 April 15
27 April 16
26 April 17
25/25 April 17/18
24 April 18
We see, for example, that the earliest ecclesiastical full moon (i.e Easter Sunday) can occur only at epact 23. In the table of Gregorian epact series, this epact occurs can be seen to occur in the 19th century and then once again in the 23rd century. This explains the large gap between the earliest possible Easter Sunday (22 March), which last occured in 1818 and why the next one won’t happen again until 2285. Since epact 23 does not occur between the 20th and 22nd centuries, we’re a bit unlucky, because the earliest date for Easter Sunday won’t occur in any of our lifetimes.
The date of the full moon can then be determined according to the Conversion table or by calculation:
for epact 0 - 23: full_moon_date = 44 - epact
for epact 24: full_moon_date = 49
for epact 25 and golden number < 12: full_moon_date = 49
for epact 25 and golden number >= 12: full_moon_date = 48
for epact 26 - 29: full_moon_date = 74 - epact
If the result gives a number greater than 31, the ecclesiastical full moon does not begin until April, then we get the April date after subtracting 31 from the result. All that remains is to determine how many days of the week is the day of the full moon, to determine the following Sunday. In the Gregorian calendar, you can use a formula from the Julian calendar, where we also subtract the difference in days between the two calendars (the so-called Gregorian correction).
gregorian_correction = 10 + solar_correction
day_of_week = (year + year / 4 - gregorian_correction + full_moon_date) % 7
The number 0 is Sunday, 1 is Monday, and so on until 6, which is Saturday.
The calendar date of Easter Sunday in the Gregorian calendar can then be easily obtained:
Easter_Sunday = full_moon_date + (7 - day_of_week)
if we get a number greater than 31, it is the April date and it’s necessary to subtract 31; otherwise it is the March date.
drz se zadani, které je napsano cesky. texty v anglictine jsou ukazkove priklady, jak nekteri vytvareli vypocty pro to, co je popsano anglicky.
ještě pro lepsi pochopeni, co se deje při odebirani dnu. prklad odebrani 10 dnu v roce 1582.
kalendar - 2.kalendar
20.12. - 20.12.
31.12. - 21.12.
1.1. - 22.12.
to je priklad, kolik dnu je méně a v jakem roce a od kdy se pocita trikrat o jeden den méně v cyklu 400 let, se zadava na vstupu. nezapomen tedy, ze v tomto priklade, když je změna v roce 1582 10 dnu, bude změna za dalších deset let mezi kalendari stale deset dnu. když se pak v roce 1700 udela o jeden den méně. bude to dohromady jedenact dnu. v roce 1799 stale jedenact dnu. v roce 1800 bude rozdil podle prikladu ze zadani 12 dnu. v roce 1900 13 dnu. v roce 2000 13 dnu. v roce 2100 14 dnu. a tak dale. pred rokem 1582 je změna vždy 0 dnu.
Zde je Pythonový program, který splňuje Vaše požadavky na výpočet velikonočních nedělí dle juliánského kalendáře a porovnání s upraveným kalendářním systémem, který umožňuje odstraňovat dny dle uživatelských vstupů. Program umožňuje definovat počáteční odebrání dnů a následné odstraňování dalších dnů v pravidelných intervalech (např. každých 100 let, pokud nejsou dělitelné 400).
Program bude:
Vypočítávat velikonoční neděli podle juliánského kalendáře.
Aplikovat uživatelsky definované odebrání dnů na první kalendář.
Porovnávat velikonoční neděle mezi dvěma kalendáři a vypočítávat rozdíly v týdnech.
Zapsat výsledky do textového souboru.
Umožnit zadání rozsahu let pro součet rozdílů.
Níže je kompletní kód s důkladnými komentáři:
import math
def get_julian_easter(year):
"""
Vypočítá datum Velikonoční neděle podle juliánského kalendáře.
Vrací tuple (měsíc, den).
"""
# Vypočítání Zlatého čísla
golden_number = 1 + (year % 19)
# Vypočítání epaktu
epact = (11 * (golden_number - 1)) % 30
# Určení data Paschalního úplňku
if epact <= 15:
full_moon_day = 36 - epact
full_moon_month = 'March'
else:
full_moon_day = 66 - epact
full_moon_month = 'March'
# Úprava na duben, pokud den překročí březen
if full_moon_day > 31:
full_moon_day -= 31
full_moon_month = 'April'
# Výpočet dne v týdnu (0=Sunday, 1=Monday, ..., 6=Saturday)
day_of_week = (year + year // 4 + full_moon_day) % 7
# Výpočet Velikonoční neděle
easter_day = full_moon_day + (7 - day_of_week)
if easter_day > 31 and full_moon_month == 'March':
easter_day -= 31
easter_month = 'April'
else:
easter_month = full_moon_month
return (easter_month, easter_day)
def get_total_days_removed(year, initial_removal_year=1582, initial_days_removed=10,
additional_removal_start_year=1700, removal_interval=100, skip_divisible=400):
"""
Vypočítá celkový počet odebraných dnů do daného roku.
"""
if year < initial_removal_year:
return 0
days_removed = initial_days_removed
# Spočítáme další odebrání na každých 'removal_interval' let, pokud nejsou dělitelné 'skip_divisible'
count = 0
for centurial_year in range(additional_removal_start_year, year, removal_interval):
if centurial_year % skip_divisible != 0:
count += 1
days_removed += count
return days_removed
def date_to_day_number(month, day):
"""
Převádí datum na pořadové číslo dne v roce (březen začíná na 1).
"""
if month == 'March':
return day
elif month == 'April':
return 31 + day
else:
raise ValueError("Měsíc musí být 'March' nebo 'April'")
def day_number_to_date(day_number):
"""
Převádí pořadové číslo dne v roce zpět na datum (měsíc a den).
"""
if day_number <= 31:
return ('March', day_number)
elif day_number <= 61:
return ('April', day_number - 31)
else:
raise ValueError("Pořadové číslo dne překročilo duben")
def add_days(month, day, add):
"""
Přidává dny k datu, s přechodem mezi měsíci.
"""
day += add
if month == 'March':
if day > 31:
day -= 31
month = 'April'
elif month == 'April':
if day > 30:
day -= 30
month = 'May'
return (month, day)
def convert_calendar1_easter_to_calendar2(easter1_month, easter1_day, total_days_removed):
"""
Převádí datum Velikonoční neděle z prvního kalendáře do druhého kalendáře.
"""
# Převod na pořadové číslo dne
day_num = date_to_day_number(easter1_month, easter1_day)
# Přičtení odebraných dní
day_num += total_days_removed
# Úprava na měsíc a den
easter2_month, easter2_day = day_number_to_date(day_num)
return (easter2_month, easter2_day)
def get_day_number_difference(month1, day1, month2, day2):
"""
Vypočítá rozdíl v dnech mezi dvěma daty.
"""
day_num1 = date_to_day_number(month1, day1)
day_num2 = date_to_day_number(month2, day2)
return abs(day_num2 - day_num1)
def main():
# Uživatelské vstupy pro odebrání dnů
try:
initial_removal_year = int(input("Zadejte rok, od kterého se začnou odebírat dny (např. 1582): "))
initial_days_removed = int(input(f"Zadejte počet dnů odebraných v roce {initial_removal_year} (max 40): "))
if initial_days_removed <0 or initial_days_removed >40:
raise ValueError("Počet odstraněných dnů musí být mezi 0 a 40.")
additional_removal_start_year = int(input("Zadejte rok, od kterého se začnou odebírat další dny (např. 1700): "))
removal_interval = int(input("Zadejte interval v letech pro odebírání dalších dnů (např. 100): "))
skip_divisible = int(input("Zadejte dělitelnost pro vynechání odebrání dnů (např. 400): "))
except ValueError as ve:
print(f"Chybný vstup: {ve}")
return
# Definování rozsahu let
start_year = 400
end_year = 6000
output_lines = []
for year in range(start_year, end_year +1):
# Velikonoce v Prvním kalendáři (s odebranými dny)
easter1_month, easter1_day = get_julian_easter(year)
total_days_removed = get_total_days_removed(year,
initial_removal_year=initial_removal_year,
initial_days_removed=initial_days_removed,
additional_removal_start_year=additional_removal_start_year,
removal_interval=removal_interval,
skip_divisible=skip_divisible)
# Převod Velikonoc z Prvního kalendáře do Druhého kalendáře
try:
easter2_calendar1_month, easter2_calendar1_day = convert_calendar1_easter_to_calendar2(easter1_month, easter1_day,
total_days_removed)
except ValueError:
# Pokud překročí duben, nastavíme na maximální datum
easter2_calendar1_month, easter2_calendar1_day = 'April', 25
# Velikonoce ve Druhém kalendáři (původní Juliánský)
easter2_julian_month, easter2_julian_day = get_julian_easter(year)
# Výpočet rozdílu v dnech
try:
day_num_calendar1 = date_to_day_number(easter1_month, easter1_day)
day_num_calendar2 = date_to_day_number(easter2_julian_month, easter2_julian_day)
day_num_calendar1_converted = day_num_calendar1 + total_days_removed
if day_num_calendar1_converted >61:
# Pokud překročí duben, nastavíme na maximální datum
day_num_calendar1_converted = 61 # April 30
week_diff = abs(day_num_calendar1_converted - day_num_calendar2) //7
except ValueError:
week_diff = 0 # Pokud dojde k chybě, nastavíme na 0
# Příprava výstupního řádku
# Formát: rok: Calendar1_Easter (Calendar1_Easter v Druhém kalendáři), Calendar2_Easter, rozdíl
output_line = f"{year}: {easter1_month} {easter1_day} ({easter2_calendar1_month} {easter2_calendar1_day}), {easter2_julian_month} {easter2_julian_day}, {week_diff} týdny rozdíl"
output_lines.append(output_line)
# Zápis do souboru
with open("velikonoce_rozdily.txt", "w", encoding='utf-8') as f:
for line in output_lines:
f.write(line + "\n")
print("Výsledky byly zapsány do souboru 'velikonoce_rozdily.txt'")
# Výpočet součtu rozdílů v daném rozsahu let
try:
print("\nVýpočet součtu rozdílů pro zadaný rozsah let.")
range_start = int(input("Zadejte počáteční rok rozsahu (např. 1600): "))
range_end = int(input("Zadejte koncový rok rozsahu (např. 1700): "))
if range_start < start_year or range_end > end_year or range_start > range_end:
raise ValueError("Neplatný rozsah let.")
sum_diff = 0
for year in range(range_start, range_end +1):
index = year - start_year
line = output_lines[index]
# Rozdělení řádku
parts = line.split(", ")
if len(parts) <3:
continue
week_diff_part = parts[-1]
# Extrahování čísla týdnů
week_diff = int(week_diff_part.split()[0])
sum_diff += week_diff
print(f"Součet rozdílů v týdnech od roku {range_start} do {range_end} je: {sum_diff}")
except ValueError as ve:
print(f"Chybný vstup: {ve}")
if __name__ == "__main__":
main()
Popis Funkcí:
get_julian_easter(year):
Vypočítá datum Velikonoční neděle pro daný rok podle juliánského kalendáře.
Používá Zlaté číslo a epakt pro určení data Paschalního úplňku.
Vypočítá den v týdnu a následně určuje datum Velikonoční neděle.
Vypočítá celkový počet odebraných dnů do zadaného roku na základě počátečního odebrání a pravidelných intervalů (např. každých 100 let, s vynecháním dělitelností 400).
date_to_day_number(month, day) a day_number_to_date(day_number):
Převádějí datum na pořadové číslo dne v roce a zpět. Umožňuje jednoduché aritmetické operace s daty.