Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DTSTART/DTEND with incorrect DATE-TIME should fail hard on parse instead of serializing to T:: #620

Open
a-schild opened this issue Sep 12, 2023 · 2 comments

Comments

@a-schild
Copy link

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
        });  
@kewisch
Copy link
Owner

kewisch commented Apr 1, 2024

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::.

@kewisch kewisch changed the title Invalid date format in export for all day events DTSTART/DTEND with incorrect DATE-TIME should fail hard on parse instead of serializing to T:: Apr 1, 2024
@kewisch
Copy link
Owner

kewisch commented Apr 1, 2024

#515 is what I had in mind, PR was abandoned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants