Skip to content

Commit

Permalink
fix: holiday range
Browse files Browse the repository at this point in the history
  • Loading branch information
Diluka committed Dec 29, 2021
1 parent f8499ce commit ac805bb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@ dist

# OS
.DS_Store

calendar.ics
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ async function createCalendar() {
for (const event of book.events()) {
console.log(event.name, event.days(), event.isHoliday(), event.isWorkingday());

const from = _.first(event.days());
const to = _.last(event.days());

calendar.createEvent({
id: `HD-CN-${+_.first(event.days())}`,
start: moment(_.first(event.days())).startOf('d'),
end: moment(_.last(event.days())).endOf('d'),
id: `HD-CN-${+from}`,
start: moment(from),
end: moment(to).add(1, 'd'),
summary: event.name + (event.isWorkingday() ? '补班' : ''),
allDay: true,
alarms: event.isWorkingday()
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"main": "index.js",
"type": "module",
"scripts": {
"start": "node ."
"start": "node .",
"test:download": "curl -sSL localhost:3000 -o calendar.ics"
},
"keywords": [],
"author": "Diluka",
Expand All @@ -26,4 +27,4 @@
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.5.1"
}
}
}

0 comments on commit ac805bb

Please sign in to comment.