50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
from icalendar import Calendar, Event
|
|
from datetime import datetime, timedelta
|
|
|
|
# Function to add event
|
|
def add_event(cal, start_date, end_date, summary):
|
|
event = Event()
|
|
event.add('summary', summary)
|
|
event.add('dtstart', start_date)
|
|
event.add('dtend', end_date + timedelta(days=1)) # end date is inclusive
|
|
event.add('dtstamp', datetime.now())
|
|
cal.add_component(event)
|
|
|
|
# Create calendar
|
|
cal = Calendar()
|
|
|
|
# First round
|
|
first_round = [
|
|
("民法", "2024-06-11", "2024-06-24"),
|
|
("刑法", "2024-06-25", "2024-07-07"),
|
|
("刑诉", "2024-07-08", "2024-07-14"),
|
|
("民诉", "2024-07-15", "2024-07-20"),
|
|
("行政法", "2024-07-21", "2024-07-26"),
|
|
("商经知", "2024-07-27", "2024-08-01"),
|
|
("三国法", "2024-08-02", "2024-08-08"),
|
|
("理论法", "2024-08-09", "2024-08-10")
|
|
]
|
|
|
|
for subject, start, end in first_round:
|
|
add_event(cal, datetime.strptime(start, "%Y-%m-%d"), datetime.strptime(end, "%Y-%m-%d"), f"第一轮复习: {subject}")
|
|
|
|
# Second round
|
|
second_round = [
|
|
("民法", "2024-08-11", "2024-08-17"),
|
|
("刑法", "2024-08-18", "2024-08-24"),
|
|
("刑诉", "2024-08-25", "2024-08-29"),
|
|
("民诉", "2024-08-30", "2024-09-03"),
|
|
("行政法", "2024-09-04", "2024-09-07"),
|
|
("商经知", "2024-09-08", "2024-09-11"),
|
|
("三国法", "2024-09-12", "2024-08-15"),
|
|
("理论法", "2024-09-16", "2024-09-17")
|
|
]
|
|
|
|
for subject, start, end in second_round:
|
|
add_event(cal, datetime.strptime(start, "%Y-%m-%d"), datetime.strptime(end, "%Y-%m-%d"), f"第二轮复习: {subject}")
|
|
|
|
# Save to file
|
|
with open("./study_plan.ics", "wb") as f:
|
|
f.write(cal.to_ical())
|
|
|