kewisch / ical.js

Javascript parser for ics (rfc5545) and vcard (rfc6350) data
https://kewisch.github.io/ical.js/
Mozilla Public License 2.0
1k stars 138 forks source link

Setting duration/duration not updated #269

Closed aheintz closed 7 years ago

aheintz commented 8 years ago

I'm trying all possible ways to set the duration of an Event without success. The existing duration isn't update when the end- or starttime is changed.

Edit There is of course possible to use Event._setProp(), but it doesn't feel like the perfect solution to use a "private" function. But it works. The duration not being updated is still a bug though.

Sample code (insignificant properties and code omitted, vcalendar created using .toString()):

BEGIN:VCALENDAR
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTAMP:20160928T080623Z
DTSTART:20160929T104500
DURATION:PT2H30M
SUMMARY:Summary
UID:m92dfbeacc0a84d1ea62e1ae2df11911c
SEQUENCE:1
END:VEVENT
END:VCALENDAR

Altering the Event using (start and end variables is Moment.js objects):

event.startDate = event.startDate.fromJSDate(start.toDate());
event.endDate = event.endDate.fromJSDate(end.toDate());
BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTAMP:20160928T080623Z
DTSTART:20160929T094500
DURATION:PT2H30M
SUMMARY:Summary
UID:m92dfbeacc0a84d1ea62e1ae2df11911c
SEQUENCE:1
DTEND:20160929T141500
END:VEVENT
END:VCALENDAR

DTSTART and DTEND is correctly updated, but not DURATION. And there is no duration setter either.

By adding a duration setter, it works as I think it should, but 1) I'm no calender guru, and 2) definitively not a javascript one so I'm not capable of creating a pull request with any tests but here's the code for the setter. However, not being able to set the duration might be a feature, but the duration not being updated is in my opinion a bug.

        set duration(value) {
            return this._setProp('duration', value);
        },
kewisch commented 8 years ago

Please note that per rfc 5545 DURATION and DTEND are actually exclusive. You can specify either one, but not both because data could be represented ambiguously.

aheintz commented 8 years ago

I'm aware of they being mutually exclusive, however I'm trying to use ical.js to manipulate events where the backend system consistently uses DTSTART and DURATION and I would like to maintain that standard.