bude se upravovat tento skript

import math

def gmod(m, n):
    """Generalized modulo function to handle negative numbers."""
    return ((m % n) + n) % n

def addspace(x):
    """Adds a leading space to single-digit numbers for alignment."""
    return f" {x}" if x < 10 else f"{x}"

def yeartype(year, cal='j'):
    """
    Determines if the year is a leap year based on the calendar.
    cal='j' for Julian, 'g' for Gregorian.
    """
    yt = 0
    if gmod(year, 4) == 0:
        yt = 1
    if cal == 'g':
        if gmod(year, 100) == 0:
            yt = 0
        if gmod(year, 400) == 0:
            yt = 1
    return yt

# Arrays as per the source code
domletname = ["G","F","E","D","C","B","A","AG","GF","FE","ED","DC","CB","BA"]
epactname = ["*(XXX)","I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII",
            "XIV","XV","XVI","XVII","XVIII","XIX","XX","XXI","XXII","XXIII","XXIV","XXV",
            "XXVI","XXVII","XXVIII","XXIX"]
martyrj = ["a","b","c","d","e","f","g","h","i","k","l","m","n","p","q","r","s","t","u"]
martyrg = ["a","b","c","d","e","f","g","h","i","k","l","m","n","p","q","r","s","t","u",
           "A","B","C","D","E","F","G","H","M","N","P"]
monthname = ["January","February","March","April","May","June","July","August","September",
            "October","November","December"]
wdname = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
yearlength = ["common","bissextile"]

def calculate_jd(year, month, day, calendar='g'):
    """Calculate the Julian Day Number for the given date."""
    if month <= 2:
        year -=1
        month +=12
    A = math.floor(year / 100)
    if calendar == 'g':
        B = 2 - A + math.floor(A /4)
    else:
        B =0
    JD = math.floor(365.25*(year + 4716)) + math.floor(30.6001*(month +1)) + day + B -1524.5
    JD_int = int(math.floor(JD + 0.5))
    return JD_int

def jul_easter(year, emod):
    """Calculates Julian Easter Sunday date."""
    a = gmod(year, 19)
    gn = a + 1  # Golden Number
    b = gmod(year, 4)
    c = gmod(year, 7)
    d = gmod((19 * a + 15), 30)
    if emod == 1 and gn == 1:
        d += 1
    e = gmod((2 * b + 4 * c - d + 6), 7)
    fmj = 113 + d  # Easter full moon [days after -92 March]
    dmj = fmj + e + 1  # Easter Sunday [days after -92 March]
    fmmj = math.floor(fmj / 31)
    fmdj = gmod(fmj, 31) + 1
    esmj = math.floor(dmj / 31)
    esdj = gmod(dmj, 31) + 1
    sc = gmod((year + 8), 28) + 1  # Number in Solar Cycle
    s = gmod((4 + math.floor(5 * year / 4)), 7)
    yt = yeartype(year, 'j')
    dl_index = s + 7 * yt
    dl = domletname[dl_index] if dl_index < len(domletname) else "Unknown"
    return [dmj, esdj, esmj, fmj, fmdj, fmmj, gn, sc, dl]

def greg_easter(year):
    """Calculates Gregorian Easter Sunday date."""
    a = gmod(year, 19)
    gn = a + 1  # Golden Number
    b = math.floor(year / 100)
    c = gmod(year, 100)
    d = math.floor(b / 4)
    e = gmod(b, 4)
    f = math.floor((b + 8) / 25)
    g = math.floor((b - f + 1) / 3)
    h = gmod((19 * a + b - d - g + 15), 30)
    i = math.floor(c / 4)
    k = gmod(c, 4)
    l = gmod((2 * e + 2 * i - h - k + 4), 7)
    m = math.floor((a + 11 * h + 22 * l) / 451)
    ep = gmod((11 * a + 8 - b + d + math.floor((8 * b + 13) / 25)), 30)
    if ep <= 23:
        fmg = 136 - ep
    elif ep in [24, 25]:
        fmg = 141
    if ep == 25 and gn > 11:
        fmg = 140
    if ep >= 26:
        fmg = 166 - ep
    dmg = 114 + h - 7 * m + l  # Easter Sunday [days after -92 March]
    fmmg = math.floor(fmg / 31)
    fmdg = gmod(fmg, 31) + 1
    esmg = math.floor(dmg / 31)
    esdg = gmod(dmg, 31) + 1
    sc = gmod((year + 8), 28) + 1  # Number in Solar Cycle
    s = gmod((6 + math.floor(5 * year / 4) - math.floor(year / 100) + math.floor(year / 400)), 7)
    yt = yeartype(year, 'g')
    dl_index = s + 7 * yt
    dl = domletname[dl_index] if dl_index < len(domletname) else "Unknown"
    return [dmg, esdg, esmg, fmg, fmdg, fmmg, gn, ep, sc, dl]

def easter_passover(year, prol=0, emod=1):
    """
    Calculates all Easter and Passover related data for a given year.
    
    Parameters:
    - year: The year to calculate.
    - prol: Show Gregorian dates before 1583 (0 for No, 1 for Yes).
    - emod: Julian Easter mode (1 for Dionysian, 2 for Armenian/Non-Chalcedonian).
    
    Returns:
    A dictionary containing all relevant fields.
    """
    # Calculate Julian Easter
    j_easter = jul_easter(year, emod)
    # Calculate Gregorian Easter
    g_easter = greg_easter(year)

    # Calculate offset between Julian and Gregorian calendar
    diff_jg = math.floor(year / 100) - math.floor(year / 400) - 2

    # Julian reckoning dates
    j_full_moon_day = j_easter[4]
    j_full_moon_month = j_easter[5]
    j_full_moon_jd = calculate_jd(year, j_full_moon_month, j_full_moon_day, 'j')

    j_sunday_day = j_easter[1]
    j_sunday_month = j_easter[2]
    j_sunday_jd = calculate_jd(year, j_sunday_month, j_sunday_day, 'j')

    # Gregorian reckoning dates (shifted Julian dates)
    fmjg = j_easter[3] + diff_jg
    fmmjg = math.floor(fmjg / 31)
    fmdjg = gmod(fmjg, 31) + 1
    # Correction: Ensure month increment is appropriate
    if fmdjg > 31:
        fmmjg +=1
        fmdjg -=31
    greg_rec_full_moon_day = fmdjg
    greg_rec_full_moon_month = fmmjg
    greg_rec_full_moon_jd = calculate_jd(year, greg_rec_full_moon_month, greg_rec_full_moon_day, 'g')

    dmgj = j_easter[0] + diff_jg
    mjg = math.floor(dmgj / 31)
    djg_day = gmod(dmgj, 31) + 1
    # Correction: Ensure month increment is appropriate
    if djg_day > 31:
        mjg +=1
        djg_day -=31
    greg_rec_sunday_day = djg_day
    greg_rec_sunday_month = mjg
    greg_rec_sunday_jd = calculate_jd(year, greg_rec_sunday_month, greg_rec_sunday_day, 'g')

    # Gregorian calendar date (standard Gregorian Easter)
    g_full_moon_day = g_easter[4]
    g_full_moon_month = g_easter[5]
    g_full_moon_jd = calculate_jd(year, g_full_moon_month, g_full_moon_day, 'g')

    g_sunday_day = g_easter[1]
    g_sunday_month = g_easter[2]
    g_sunday_jd = calculate_jd(year, g_sunday_month, g_sunday_day, 'g')

    # Solar Cycle and Dominical Letters
    sc = j_easter[7]
    dl_j = j_easter[8]
    dl_g = g_easter[9] if (prol ==1 or year >=1583) else "--"

    # Golden Number and Epact
    gn = j_easter[6]
    ep = g_easter[7]

    # Martyrology letters
    if (prol ==1 or year >=1583):
        if 1 <= ep <= len(martyrg):
            litmartyrg = martyrg[ep -1]
        elif ep ==0 and len(martyrg) >29:
            litmartyrg = martyrg[29]
        else:
            litmartyrg = "--"
    else:
        litmartyrg = "--"

    litmartyrj = martyrj[gn -1] if 1 <= gn <= len(martyrj) else "--"

    # Epact handling
    if prol ==0 and year < 1582:
        epact = "--"
    else:
        if ep < len(epactname):
            epact = epactname[ep]
        else:
            epact = f"Unknown({ep})"
        if ep ==25 and gn >11:
            epact = "25"

    # Offset between Julian and Gregorian calendar
    offset_j_g = f"{diff_jg} days" if not (prol ==0 and year <1582) else "--"

    # deljg: From Gregorian until Julian Easter Sunday
    deljg = (j_sunday_jd - g_sunday_jd) if (prol ==1 or year >=1583) else "--"

    # Passover calculation
    a = gmod((12 * year + 12), 19)
    b = gmod(year, 4)
    s = (5 * (1979335 - 313 * year) + (765433 * a)) / 492480 + b /4
    q = math.floor(s)
    r = s - q
    c_calc = gmod((q + 3 * year +5 * b +1),7)
    dmh = q + diff_jg + 92
    p =0
    if c_calc in [2,4,6]:
        p =1
    if c_calc ==1 and a >6 and r >1366/2160:
        p =2
    if c_calc ==0 and a >11 and r >23268/25920:
        p =1
    dmh += p

    if prol ==0 and year <1583:
        dmh_jd = dmh - diff_jg
        mh = math.floor((dmh_jd -62)/30.6) +2
        dh = math.floor(dmh_jd -62 -30.6 * math.floor((dmh_jd -62)/30.6)) +1
        passover_jd = calculate_jd(year, mh, dh, 'j')
    else:
        dmh_jd = dmh
        mh = math.floor((dmh_jd -62)/30.6) +2
        dh = math.floor(dmh_jd -62 -30.6 * math.floor((dmh_jd -62)/30.6)) +1
        passover_jd = calculate_jd(year, mh, dh, 'g')

    ddhj = j_sunday_jd - passover_jd  # From Passover until Julian Easter Sunday
    if (prol ==1 or year >=1583):
        ddhg = g_sunday_jd - passover_jd  # From Passover until Gregorian Easter Sunday
    else:
        ddhg = "--"

    # Weekday Passover
    wh = gmod(c_calc + p +5,7)
    wd_passover = wdname[wh] if 0 <= wh < len(wdname) else "--"

    # Passover Day and Month
    passover_day = addspace(dh) if isinstance(dh, int) else "--"
    passover_month = monthname[mh -1] if isinstance(mh, int) and 1 <= mh <=12 else "--"

    # Amundi
    amundi = year + 3760

    # Passover Feast Date and JD
    passover_label = f"15 Nisan {amundi} AM"
    # Recompute passover_jd to ensure consistency
    passover_jd = calculate_jd(year, mh, dh, 'g') if (prol ==1 or year >=1583) else calculate_jd(year, mh, dh, 'j')

    # Prepare record
    record = {
        "Year": str(year),
        "Offset between Julian and Gregorian calendar": offset_j_g,
        "Number in Solar Cycle": str(sc),
        "Dominical Letter - Julian reckoning": dl_j,
        "Dominical Letter - Gregorian reckoning": dl_g,
        "Lunar age parameters - Golden Number": str(gn),
        "Lunar age parameters - Gregorian Epact": epact,
        "Martyrology letters - Julian reckoning": litmartyrj,
        "Martyrology letters - Gregorian reckoning": litmartyrg,
        "Julian reckoning": {
            "Easter Full Moon (luna XIV)": f"{j_full_moon_day} {j_full_moon_month} (JD {j_full_moon_jd})",
            "Easter Sunday": f"{j_sunday_day} {j_sunday_month} (JD {j_sunday_jd})"
        },
        "Gregorian reckoning": {
            "Easter Full Moon (luna XIV)": f"{greg_rec_full_moon_day} {greg_rec_full_moon_month} (JD {greg_rec_full_moon_jd})" if (prol ==1 or year >=1583) else "--",
            "Easter Sunday": f"{greg_rec_sunday_day} {greg_rec_sunday_month} (JD {greg_rec_sunday_jd})" if (prol ==1 or year >=1583) else "--"
        },
        "Gregorian calendar date": {
            "Easter Full Moon (luna XIV)": f"{g_full_moon_day} {g_full_moon_month} (JD {g_full_moon_jd})" if (prol ==1 or year >=1583) else "--",
            "Easter Sunday": f"{g_sunday_day} {g_sunday_month} (JD {g_sunday_jd})" if (prol ==1 or year >=1583) else "--"
        },
        "Jewish Passover Feast": f"{passover_label}    {wd_passover} {passover_day} {passover_month} (JD {passover_jd})",
        "From Gregorian until Julian Easter Sunday": f"{deljg} days",
        "From Passover until Gregorian Easter Sunday": f"{ddhg} days" if (prol ==1 or year >=1583) else "--",
        "From Passover until Julian Easter Sunday": f"{ddhj} days"
    }

    return record

def main():
    # Settings
    prol = 0  # Show Gregorian dates before 1583 - No
    emod = 1  # Julian Easter mode - Dionysian

    # Open the output file
    with open("calculator_easter_data.txt", "w", encoding="utf-8") as f:
        # Iterate through years
        for year in range(400, 6001):
            # Calculate data using easter_passover function
            record = easter_passover(year, prol, emod)

            # Write Year
            f.write(f"Year: {record['Year']}\n")
            f.write("\n")  # Přidání prázdného řádku

            # Write Offset between Julian and Gregorian calendar
            f.write(f"Offset between Julian and Gregorian calendar: {record['Offset between Julian and Gregorian calendar']}\n")
            f.write("\n")  # Přidání prázdného řádku

            # Write Number in Solar Cycle and Dominical Letters
            f.write(f"Number in Solar Cycle: {record['Number in Solar Cycle']}\n")
            f.write(f"Dominical Letter - Julian reckoning: {record['Dominical Letter - Julian reckoning']}  Dominical Letter - Gregorian reckoning: {record['Dominical Letter - Gregorian reckoning']}\n")

            # Write Lunar age parameters and Epact
            f.write(f"Lunar age parameters - Golden Number: {record['Lunar age parameters - Golden Number']}  Gregorian Epact: {record['Lunar age parameters - Gregorian Epact']}\n")

            # Write Martyrology letters
            f.write(f"Martyrology letters - Julian reckoning: {record['Martyrology letters - Julian reckoning']}  Martyrology letters - Gregorian reckoning: {record['Martyrology letters - Gregorian reckoning']}\n")
            f.write("\n")  # Přidání prázdného řádku

            # Write Julian reckoning dates
            f.write("Julian reckoning\t\tJulian calendar date\t\t\tGregorian calendar date\n")
            f.write(f"Easter Full Moon (luna XIV)\t{record['Julian reckoning']['Easter Full Moon (luna XIV)']}\t\t{record['Gregorian reckoning']['Easter Full Moon (luna XIV)']}\n")
            f.write(f"Easter Sunday\t\t\t{record['Julian reckoning']['Easter Sunday']}\t\t{record['Gregorian reckoning']['Easter Sunday']}\n")
            f.write("\n")  # Přidání prázdného řádku

            # Write Gregorian reckoning dates
            f.write("Gregorian reckoning\t\tGregorian calendar date\n")
            f.write(f"Easter Full Moon (luna XIV)\t{record['Gregorian calendar date']['Easter Full Moon (luna XIV)']}\n")
            f.write(f"Easter Sunday\t\t\t{record['Gregorian calendar date']['Easter Sunday']}\n")
            f.write("\n")  # Přidání prázdného řádku

            # Write Jewish Passover Feast
            f.write(f"Jewish Passover Feast\t{record['Jewish Passover Feast']}\n")
            f.write("\n")  # Přidání prázdného řádku

            # Write deljg, delhg, delhj
            f.write(f"From Gregorian until Julian Easter Sunday {record['From Gregorian until Julian Easter Sunday']}\n")
            f.write(f"From Passover until Gregorian Easter Sunday {record['From Passover until Gregorian Easter Sunday']}\n")
            f.write(f"From Passover until Julian Easter Sunday {record['From Passover until Julian Easter Sunday']}\n")
            f.write("\n")  # Přidání prázdného řádku

            # Add separator
            f.write("-" * 80 + "\n\n")

            # Optional: Print progress every 1000 years
            if year % 1000 == 0:
                print(f"Processed year: {year}")

    print("Easter data calculation completed. Check 'calculator_easter_data.txt' for results.")

if __name__ == "__main__":
    main()





uprav skript tak, ze se na vystupu pta, co chce uživatel vypsat za data. bude se používat pouze angličtina.

moznost A po stsiku klavesy A bude soucasne vypsani dat
A - list all the dates for Easter

moznost B po stisku klavesy B bude vypsani velikonocnich nedel. 
B - list of Easter Sundays
pak se vypise podnabídka
1 - Julian and Gregorian calendar
2 - Julian and Gregorian calendar with conversions
3 - Julian calendar
4 - Julian calendar with conversion
5 - Gregorian calendar
6 - Gregorian calendar with conversion


co se vypise je zrejme z nazvu. pred rokem 1583 se gregorianske hodnoty vypisuji jako prazdne --
format je 
na zacatku, co se vypisuje za nabidku napr anglicke nazvy z B4
a pak nasleduji  data year month day (JD) 
v pripade prevodu year month day (JD) [year month day (JD)]
každý rok bude na jednom radku, v pripade vypisovani juliánského i gregoriánského se tyto oddeli středníkem, po kterem nasleduje jedno prazdne misto

moznost C po stisku klavesy C bude vypsani velikonocnich uplnku.
C - list of Easter Full Moons
pak se vypise podnabídka
1 - Julian and Gregorian calendar
2 - Julian and Gregorian calendar with conversions
3 - Julian calendar
4 - Julian calendar with conversion
5 - Gregorian calendar
6 - Gregorian calendar with conversion

co se vypise je zrejme z nazvu. pred rokem 1583 se gregorianske hodnoty vypisuji jako prazdne --
format je 
na zacatku, co se vypisuje za nabidku napr anglicke nazvy z C4
a pak nasleduji  data year month day (JD) day of the week
v pripade prevodu year month day (JD) day of the week [year month day (JD) day of the week]
každý rok bude na jednom radku, v pripade vypisovani juliánského i gregoriánského se tyto oddeli středníkem, po kterem nasleduje jedno prazdne misto

moznost D po stisku klavesy D bude vypsani zidovskych velikonoc.
D - list of Jewish Passover Feast
pak se vypise podnabídka
1 - Passover
2 - Passover with Julian and Gregorian calendar conversions
3 - Passover with Julian calendar conversion
4 - Passover with Gregorian calendar conversion

vypisy budou analogicke predchozimu

ještě se nabízí moznost zmacknout klávesu X (exit), která ukonci program.
při stisku jiné klavesy program nedela nic.