Skip to content

Commit

Permalink
fix: 馃悰 Adapted to apple holiday calendar dtend is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenull committed Sep 9, 2022
1 parent 80eaab1 commit 858757d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/util/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ import dayjs from 'dayjs'
const { dtstart, dtend, summary, description } = event
const hasTime = dtstart.type === 'date-time'

let end = dtend?.value
// Adapted to apple holiday calendar dtend is empty
let end = dtend?.value || dtstart.value
if (!hasTime) {
const _end = dayjs(dtend.value).subtract(1, 'day').endOf('day')
/**
* Full day events are available in three formats
* dtstart 2022-09-09
* dtend undefined (apple holiday calendar: https://calendars.icloud.com/holidays/cn_zh.ics)
* dtend 2022-09-10 (google calendar)
* dtend 2022-09-09 (https://www.shuyz.com/githubfiles/china-holiday-calender/master/holidayCal.ics)
*/
const _end = dayjs(end).subtract(1, 'day').endOf('day')
if (_end.isSameOrAfter(dayjs(dtstart?.value), 'day')) end = _end.format()
}

Expand Down

0 comments on commit 858757d

Please sign in to comment.