Skip to content

optimize ics output file size #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2025

Conversation

GodHu777777
Copy link
Contributor

Definition

同一课程名 同一上课节次(e.g.1-2节) 每一周的同一天 视为my_course(即259行遍历timeArrangementi

优化思路

由于原来的导出文件是把每门课程每一次上课都记为一个VEVENT,这样相对臃肿,基于ics的recurrence rule,可以将定期发生(在课程表的情况下就是每周发生)的事件统一记为一个VEVENT. 即每个my_course都可以记为1个或若干个含有RRULEVEVENT

考虑到如下情况:

学期中间有清明节调课,《初级英语》的课程安排变成了 周三12节(1-8周,10-16周)
因为这两个分段是在一个i的,只要记为两个VEVENT,第一个VEVENT中: {DTSTARTDTEND设为1周周三的上课时间(2025.2.19 8:30-10:05) UNTIL设为8周周三的23:59:59} 第二个VEVENT中: {DTSTARTDTEND设为10周周三的上课时间(2025.4.23 8:30-10:05) UNTIL设为16周周三的23:59:59}

为什么23:59:59 (Line: 287)

因为UNTIL是时间发生的截止时间,因为我担心冲突,所以设置为23:59:59,那么,在当天的23:59:59之前的课都可以发生

@BenderBlog
Copy link
Owner

23:59:59 可以改成转天的 0:00:00 ?

@GodHu777777
Copy link
Contributor Author

理论上应该可以,而且until好像不写hhmmss只写日期,是包含该日期发生的日程(这个是我问gemini的,官方doc给的示例好像没看到)

@BenderBlog
Copy link
Owner

vevent += "RRULE:FREQ=WEEKLY;UNTIL=${day.add(weeks: j).set(hour:23, minute:59, second:59).format(pattern: 'yyyyMMddTHHmmss')}\n";

如果延续您的思想,我想可以写成

vevent += "RRULE:FREQ=WEEKLY;UNTIL=${day.add(weeks: j, days:1).format(pattern: 'yyyyMMddTHHmmss')}\n";

不过具体 rrule 咋搞的我不清楚,我感觉也许不需要那个时间。

@GodHu777777
Copy link
Contributor Author

应该是可以,还劳烦你本地调试一下了🙂

@BenderBlog BenderBlog merged commit 967375a into BenderBlog:main Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants