ical.js
ical.js copied to clipboard
DTSTART/DTEND with incorrect DATE-TIME should fail hard on parse instead of serializing to `T::`
ical.js in version 1.5.0 On windows 11 and debian with nodejs version 16
Importing this ical file works fine:
BEGIN:VCALENDAR
PRODID:-//eluceo/ical//2.0/EN
VERSION:2.0
CALSCALE:GREGORIAN
X-PUBLISHED-TTL:PT1H
X-WR-CALNAME:Calname
BEGIN:VEVENT
UID:[email protected]
DTSTAMP:20230912T115144Z
LAST-MODIFIED:20230523T064918Z
SUMMARY:Kinderwoche
DESCRIPTION:
DTSTART:20231008
DTEND:20231013
LOCATION:Mylocation
ORGANIZER:mailto:[email protected]
SEQUENCE:1
X-MICROSOFT-CDO-ALLDAYEVENT:TRUE
END:VEVENT
END:VCALENDAR
But when I export it back out, the all day events with no time have an invalid time part in the ics file/content The DTSTART and DTEND fierlds/values have a completely different format, with - delimiters and T:: at the end.
BEGIN:VCALENDAR
PRODID:-//iCal.js churchtool calendar merger
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
UID:[email protected]
DTSTAMP:20230912T100054Z
LAST-MODIFIED:20230523T064918Z
SUMMARY:Kinderwoche
DESCRIPTION:
DTSTART:2023-10-08T::
DTEND:2023-10-13T::
LOCATION:Mylocation
ORGANIZER:mailto:[email protected]
SEQUENCE:1
X-MICROSOFT-CDO-ALLDAYEVENT:TRUE
END:VEVENT
END:VCALENDAR
ee use the toString() method to produce the ical file/content
let comp = new ICAL.Component(['vcalendar', [], []]);
comp.updatePropertyWithValue('prodid', '-//iCal.js churchtool calendar merger');
comp.updatePropertyWithValue('version', '2.0');
comp.updatePropertyWithValue('calscale', 'GREGORIAN');
for (const srcEvent of newCalendarContent[key]) {
// Add the components from imported ical
comp.addSubcomponent(srcEvent);
}
logger.info("Output to: "+singleConfig.output.fileName);
fs.writeFile(singleConfig.output.fileName, comp.toString(), err => {
if (err) {
console.error(err);
}
// file written successfully
});
The default type for DTSTART and DTEND is DATE-TIME, so it should be:
DTSTART;VALUE=DATE:20231008
DTEND;VALUE=DATE:20231013
Granted, it should fail hard in strict mode, and be lenient in strict mode. I believe there was some code added there, but I didn't double check. Let's leave this as an enhancement to fail correctly without using T::.
https://github.com/kewisch/ical.js/issues/515 is what I had in mind, PR was abandoned.