devsoc-unsw / devsoc-unsw/notangles

Bug of Saving Timetable into Calendar

Open
#1,016 0 comments 0 reactions 1 assignee Claimed by @jason4193 View on GitHub
🐞 bug 🐛
Dominant language
TypeScript
Stars
79
Forks
9
PR merge metrics
No merged PRs in 30d

Description

Observed a bug for the ICS export function, where the download ICS file only contain `null` no matter user is guest or login.

After investigated on the old `downloadICS` function (3 years ago), seem the init of the `currDate` for each event using `dayjs` is outdated which causing the returning an `NaN` start time and end time. This lead to the `createEvents` function compute wrong and insert `null` in to the ICS file.

```typescript
const generateDateArray = (
firstDayOfTerm: string,
timezone: number,
hour: number,
day: number,
week: number,
): DateArray => {
// Updated
const currDate = dayjs(firstDayOfTerm, 'YYYY-MM-DD', true)
.subtract(timezone, 'hour')
.add(week - 1, 'week')
.add(day - 1, 'day')
.add(hour, 'hour');

// Old
// const currDate = dayjs(firstDayOfTerm + `T00:00:00.000Z`)
// .subtract(timezone, 'h')
// .add(week - 1, 'w')
// .add(day - 1, 'd')
// .add(hour, 'h');

return [currDate.year(), currDate.month() + 1, currDate.date(), currDate.hour(), currDate.minute()];
};
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.