From 2c2e8610c3f0e8737062f2e1419c5765a3ce7ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=BCller?= Date: Wed, 13 Oct 2021 13:10:35 +0200 Subject: [PATCH] Fixing bug that prevented the middleware from working with Thunderbird on Microschrott Windoof - FUCK FILE ENCODINGS - FUCK BILL GATES --- .../icalgenerator/icalgenerator.service.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/models/rapla-middleware/icalgenerator/icalgenerator.service.ts b/src/models/rapla-middleware/icalgenerator/icalgenerator.service.ts index e4f443f..c4b3f77 100644 --- a/src/models/rapla-middleware/icalgenerator/icalgenerator.service.ts +++ b/src/models/rapla-middleware/icalgenerator/icalgenerator.service.ts @@ -48,7 +48,7 @@ export const parseIcal = function (icalContents: string): iCalFile { header = headerMatch[0]; } - header = header.substr(0, header.lastIndexOf('\n')); + header = header.substr(0, header.lastIndexOf('\n') + 1); let events: iCalEvent[] = []; let match: any; @@ -67,7 +67,7 @@ export const parseIcal = function (icalContents: string): iCalFile { }; }; -export const getDuration = function(event: string): number { +export const getDuration = function (event: string): number { let startRegex: RegExp = /DTSTART.*?(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z?\r/gm; // Fix this, doesnt match \n but matching Z doesnt work all the time let endRegex: RegExp = /DTEND.*?(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z?\r/gm; // s.o. @@ -80,7 +80,7 @@ export const getDuration = function(event: string): number { let startDtDay = 0; let startDtHour = 0; let startDtMinute = 0; - if(startMatch) { + if (startMatch) { startDtYear = parseInt(startMatch[1]); startDtMonth = parseInt(startMatch[2]); startDtDay = parseInt(startMatch[3]); @@ -94,7 +94,7 @@ export const getDuration = function(event: string): number { let endDtDay = 0; let endDtHour = 0; let endDtMinute = 0; - if(endMatch) { + if (endMatch) { endDtYear = parseInt(endMatch[1]); endDtMonth = parseInt(endMatch[2]); endDtDay = parseInt(endMatch[3]); @@ -106,14 +106,14 @@ export const getDuration = function(event: string): number { let endDt = new Date(endDtYear, endDtMonth - 1, endDtDay, endDtHour, endDtMinute); return endDt.getHours() - startDt.getHours(); -} +}; export const serializeIcal = function (ical: iCalFile): string { let resString = ical.head; ical.body.forEach((event) => { resString += event.content + '\n'; }); - resString += 'END:VCALENDAR'; + resString += 'END:VCALENDAR\n'; return resString; };