Skip to content

Commit

Permalink
fix: set alarm
Browse files Browse the repository at this point in the history
  • Loading branch information
Diluka committed Dec 30, 2021
1 parent 8d5b806 commit a173b0b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
22 changes: 14 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,26 @@ async function createCalendar() {
const from = _.first(event.days());
const to = _.last(event.days());

calendar.createEvent({
const ev = calendar.createEvent({
id: `HD-CN-${+from}`,
start: moment(from),
end: moment(to).add(1, 'd'),
summary: event.name + (event.isWorkingday() ? '补班' : ''),
allDay: true,
alarms: event.isWorkingday()
? event.days().map((o) => ({
type: 'display',
trigger: moment(o).add(-4, 'hours'),
description: '明天要上班记得定闹钟',
}))
: undefined,
});

if (event.isWorkingday()) {
const description = '明天要上班记得定闹钟';
ev.description(description);

event.days().map((o) =>
ev.createAlarm({
type: 'display',
trigger: moment(o).add(-4, 'hours'),
description,
}),
);
}
}

return calendar;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chinese-holidays-ics",
"version": "1.1.0",
"version": "1.2.0",
"description": "中国节假日日历订阅服务器",
"private": true,
"repository": "https://github.com/Diluka/chinese-holidays-ics",
Expand Down

0 comments on commit a173b0b

Please sign in to comment.