Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit dd39d18

Browse files
author
the-djmaze
committed
Changes #1603
1 parent 047fd62 commit dd39d18

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

plugins/view-ics/message.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,27 @@
1111
dateRegEx = /(TZID=(?<tz>[^:]+):)?(?<year>[0-9]{4})(?<month>[0-9]{2})(?<day>[0-9]{2})T(?<hour>[0-9]{2})(?<minute>[0-9]{2})(?<second>[0-9]{2})(?<utc>Z?)/,
1212
parseDate = str => {
1313
let parts = dateRegEx.exec(str)?.groups,
14-
options = {dateStyle: 'long', timeStyle: 'short'};
14+
options = {dateStyle: 'long', timeStyle: 'short'},
15+
date = (parts ? new Date(
16+
parseInt(parts.year, 10),
17+
parseInt(parts.month, 10) - 1,
18+
parseInt(parts.day, 10),
19+
parseInt(parts.hour, 10),
20+
parseInt(parts.minute, 10),
21+
parseInt(parts.second, 10)
22+
) : new Date(str));
1523
parts?.tz && (options.timeZone = parts.tz);
16-
return (parts ? new Date(
17-
parseInt(parts.year, 10),
18-
parseInt(parts.month, 10) - 1,
19-
parseInt(parts.day, 10),
20-
parseInt(parts.hour, 10),
21-
parseInt(parts.minute, 10),
22-
parseInt(parts.second, 10)
23-
) : new Date(str)).format(options);
24+
try {
25+
return date.format(options);
26+
} catch (e) {
27+
console.error(e);
28+
if (options.timeZone) {
29+
// TODO: handle messy vtimezones
30+
// VTIMEZONEs[options.timeZone];
31+
options.timeZone = undefined;
32+
return date.format(options);
33+
}
34+
}
2435
};
2536

2637
attachmentsPlace.after(Element.fromHTML(`

0 commit comments

Comments
 (0)