Skip to content

Commit ecb2a15

Browse files
author
NewSkyLine
committed
Fixed timezone
1 parent 5cacdf0 commit ecb2a15

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
"author": "",
1414
"license": "ISC",
1515
"devDependencies": {
16+
"@types/luxon": "^3.4.2",
1617
"@types/node": "^20.11.5",
1718
"gh-pages": "^6.1.1",
1819
"typescript": "^5.3.3"
1920
},
2021
"dependencies": {
2122
"ical-generator": "^6.0.1",
2223
"ics": "^3.7.2",
24+
"luxon": "^3.4.4",
2325
"webuntis": "^2.0.3"
2426
}
2527
}

src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import ical, { ICalCalendarMethod } from "ical-generator";
2626
events = parseTimetable(timetable);
2727

2828
// Write ics file
29-
const calendar = ical({ name: "Stundenplan" });
29+
const calendar = ical({ name: "Stundenplan", timezone: "Europe/Vienna" });
3030

3131
events.forEach((event) => {
3232
calendar.createEvent({

src/untis.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { DateTime } from "luxon";
2+
13
export function parseDate(date: number, time: number): Date {
24
const year = Math.floor(date / 10000);
35
const month = Math.floor((date % 10000) / 100);
@@ -6,5 +8,13 @@ export function parseDate(date: number, time: number): Date {
68
const hour = Math.floor(time / 100);
79
const minute = time % 100;
810

9-
return new Date(year, month - 1, day, hour, minute);
11+
const viennaDateTime = DateTime.fromObject({
12+
year,
13+
month,
14+
day,
15+
hour,
16+
minute,
17+
}).setZone("Europe/Vienna");
18+
19+
return viennaDateTime.toJSDate();
1020
}

0 commit comments

Comments
 (0)