SeabertYuan / better-workday-calendar

MIT License
4 stars 1 forks source link

[Bug] Error occurs when parsing a calendarObject #3

Closed YiRanMushroom closed 2 days ago

YiRanMushroom commented 2 weeks ago

When using the export feature of this extension, I found the ics file fails to be imported in google calendar.

Further investigation shows that this is because of some of the courses in workday have a tag (Alternate weeks) in the place where which days of the week the courses are held is displayed.

eg: image

This will cause Not A Number being append to the string generated. This is probably because it cannot find the key in the map, and causes some data to become undefined, and when converting to a number explicitly it becomes NAN (I am just guessing because I don't know js well).

image

Please considering fix this, probably we may should also change the INTERVAL to be 2 if we found this tag. (I am not sure if that's the case).

SeabertYuan commented 2 weeks ago

Thank for this report, this is an interesting problem... I'll take a look and see what I can do

YiRanMushroom commented 1 week ago

I think a quick fix could be throw an exception when the key is not presented in the map, and push the calendarObject to calendarObjects after that. So if there is an exception then the code would not execute. Definitely need to catch that though.

This will not lost any courses because the problem comes from the function fails to interpret "(Altenalte" and "weeks)" as valid days in a week, but still created a calendarObject, which is redundant and erroneous.

But if you want to change the interval when the course being held in alternate weeks then there are much more work to do.

SeabertYuan commented 2 days ago

Apologies for the slow updates, I believe this bug is (temporarily) fixed by simply ignoring anything that's not a day of the week. In the future we may add support for these tags. Thanks for this report!