-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_calendars.py
39 lines (30 loc) Β· 1.23 KB
/
generate_calendars.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import calendar
def generate_year_calendar(year):
year_calendar = ""
for month in range(1, 13):
month_calendar = calendar.monthcalendar(year, month)
month_name = calendar.month_name[month]
year_calendar += f"#### {month_name}\n\n"
year_calendar += "| Mon(ζ) | Tue(η«) | Wed(ζ°΄) | Thu(ζ¨) | Fri(ι) | Sat(ε) | Sun(ζ₯) |\n"
year_calendar += "| :-----: | :-----: | :-----: | :-----: | :-----: | :-----: | :-----: |\n"
for week in month_calendar:
week_row = "|"
for day in week:
if day == 0:
week_row += " |"
else:
week_row += f" {day:2d} |"
year_calendar += week_row + "\n"
year_calendar += "\n"
return year_calendar
def save_calendar_to_file(year, calendar_data):
filename = f"{year}.md"
with open(filename, "w") as file:
file.write(calendar_data)
start_year = 2024
end_year = 2099 # Change this to the desired end year
for year in range(start_year, end_year + 1):
year_calendar_md = generate_year_calendar(year)
save_calendar_to_file(year, year_calendar_md)
print(f"Generated {year}.md")
print("Generation complete!")