#1: Add possibility to create whole-day events
Jenkins Production Deployment

This commit is contained in:
2022-12-28 12:15:01 +01:00
parent d85f9a992b
commit 93c70b0e1d
4 changed files with 34 additions and 17 deletions
@@ -34,8 +34,13 @@ const serializeIcalEvent = (icalevent: iCalEvent): string => {
returnString += 'UID:' + icalevent.uid;
returnString += 'DTSTAMP:' + icalevent.created;
returnString += 'ORGANIZER:' + icalevent.organizer;
returnString += 'DTSTART;TZID=Europe/Berlin:' + icalevent.start;
returnString += 'DTEND;TZID=Europe/Berlin:' + icalevent.end;
if(icalevent.wholeDay) {
returnString += 'DTSTART;VALUE=DATE:' + icalevent.start;
returnString += 'DTEND;VALUE=DATE:' + icalevent.end;
} else {
returnString += 'DTSTART;TZID=Europe/Berlin:' + icalevent.start;
returnString += 'DTEND;TZID=Europe/Berlin:' + icalevent.end;
}
returnString += 'SUMMARY:' + icalevent.summary;
if(!isNullOrBlank(icalevent.description)) returnString += 'DESCRIPTION:' + icalevent.description;
if(!isNullOrBlank(icalevent.location)) returnString += 'LOCATION:' + icalevent.location;
@@ -91,26 +96,32 @@ const createIcalEvent = (event: Event): iCalEvent => {
uid: event.uuid + '\n',
created: formatDate(event.createdDate) + 'Z\n',
organizer: event.createdBy + '\n',
start: formatDate(event.startDateTime) + '\n',
end: formatDate(event.endDateTime) + '\n',
start: formatDate(event.startDateTime, event.wholeDay) + '\n',
end: formatDate(event.endDateTime, event.wholeDay, true) + '\n',
summary: event.name + '\n',
description: description,
location: location,
url: url,
wholeDay: event.wholeDay,
footer: 'END:VEVENT\n'
};
};
const formatDate = (date: Date): string => {
const formatDate = (date: Date, wholeDayFormat: boolean = false, isEndDate: boolean = false): string => {
let returnString = '';
// We need to do this for whole day events as otherwise the event ends one day too early
if(wholeDayFormat && isEndDate) date.setDate(date.getDate() + 1)
returnString += date.getFullYear();
returnString += (date.getMonth() + 1).toString().padStart(2, '0'); // +1 Because JS sucks
returnString += date.getDate().toString().padStart(2, '0');
returnString += 'T';
returnString += date.getHours().toString().padStart(2, '0');
returnString += date.getMinutes().toString().padStart(2, '0');
returnString += date.getSeconds().toString().padStart(2, '0');
if(!wholeDayFormat) {
returnString += 'T';
returnString += date.getHours().toString().padStart(2, '0');
returnString += date.getMinutes().toString().padStart(2, '0');
returnString += date.getSeconds().toString().padStart(2, '0');
}
return returnString;
};
@@ -132,6 +143,7 @@ export interface iCalEvent {
description: string;
location: string;
url: string;
wholeDay: boolean;
footer: string;
}