GAS-ICS-Sync icon indicating copy to clipboard operation
GAS-ICS-Sync copied to clipboard

Split up recurring event [Request]

Open vivimage opened this issue 1 year ago • 20 comments

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

Is it possible to sync recurring event not as a recurring event but split it up into individual events?

Additional context

No response

vivimage avatar May 09 '24 08:05 vivimage

In theory yes. ical.js has a RecurExpansion class to provide the needed start dates.

jonas0b1011001 avatar May 09 '24 08:05 jonas0b1011001

Thank you for an insight! Which part of the script will I need to change to add this? Will be grateful, if you can lead me

vivimage avatar May 09 '24 17:05 vivimage

Try this: add

if (event.hasProperty('rrule')||event.hasProperty('rdate')){
    let icalEvent = new ICAL.Event(event, {strictExceptions: true});
    let dtstart = event.getFirstPropertyValue('dtstart');
    let recExpand = new ICAL.RecurExpansion({component: event, dtstart: dtstart});
    let duration = icalEvent.endDate.subtractDate(icalEvent.startDate);
    let uid = event.getFirstPropertyValue('uid').toString();
    let nextStart;
    event.removeProperty('rrule');
    event.removeProperty('rdate');
    event.removeProperty('exdate');
    let i = 0;
    while (i < 30 && (nextStart = recExpand.next())){
      event.updatePropertyWithValue('dtstart', nextStart);
      nextStart.addDuration(duration);
      event.updatePropertyWithValue('dtend', nextStart);
      event.updatePropertyWithValue('uid', uid + nextStart.toICALString());
      icsEventsIds.push('uid', uid + nextStart.toICALString());
      let component = new ICAL.Component.fromString(event.toString());
      processEvent(component, calendarTz);
      i++;
    }
    return;
  }

right above https://github.com/derekantrican/GAS-ICS-Sync/blob/3c36a55aaa61ac6abee037ba7a5e7d8334620b36/Helpers.gs#L291

jonas0b1011001 avatar May 09 '24 19:05 jonas0b1011001

Thank you! It almost works, but sometimes duplicates an event. Weird that its not always happening. On some reoccurrence it's not happening. image

vivimage avatar May 10 '24 20:05 vivimage

I can't reproduce that, have you done any other changes to the script? What settings are you using?

jonas0b1011001 avatar May 11 '24 13:05 jonas0b1011001

Default settings, default script. Only with changes you provided. I delete the calendar and let the script create a calendar from scratch.

Seems like it's happening if one event in reccuring series is changed

vivimage avatar May 13 '24 18:05 vivimage

Seems like it's happening if one event in reccuring series is changed

That makes sense, i'll look into it.

jonas0b1011001 avatar May 13 '24 18:05 jonas0b1011001

Give this version a try.

There have been changes in various places, i think it's easier to share the whole script than list all changes here.

jonas0b1011001 avatar May 14 '24 09:05 jonas0b1011001

Thank you very much! Duplicating of events stopped.

I'm noticed one issue. Again only happening with edited events in reccuring series. Its not picking up the change in the timezones, when expanding.

I moved to another country and changed the Google calendar timezone. The expanded event (from edited event in recurring series) haven't picked up the change. So there is difference between original event time and expanded event time.

vivimage avatar May 15 '24 04:05 vivimage

Again only happening with edited events in reccuring series.

Can you share a minimal *.ics you are testing this with? Google calendar for example 'discards' timezones of recurrence exceptions when exporting the calendar.

jonas0b1011001 avatar May 15 '24 05:05 jonas0b1011001

https://calendar.google.com/calendar/ical/6c199906f611efbb417e414973337dd12e87e267e0e753c311b657703e67d030%40group.calendar.google.com/private-00638ada960c706c9eb7cd467a881913/basic.ics

I unfortunately deleted the event that was causing the issue.

vivimage avatar May 15 '24 05:05 vivimage

Any work around that Google discards timezones from recurrence exceptions?

vivimage avatar May 15 '24 05:05 vivimage

Any work around that Google discards timezones from recurrence exceptions?

No, that's just the way google handles it.

Nevertheless the events should all be at the correct timeslot (albeit in a wrong timezone) in regards to the timezone set in your target calendar. Is that the case?

jonas0b1011001 avatar May 15 '24 06:05 jonas0b1011001

I can't reproduce the issue that I was having yet. The events were appearing in different timeslots

vivimage avatar May 15 '24 07:05 vivimage

image

Started receiving this error on execution.

The .ics: https://calendar.google.com/calendar/ical/5777ff39396824cd7783b1699ebf40a794c091a7e842ea285efd8a4691c6903b%40group.calendar.google.com/private-cc298dcacf59effca281fea225bec509/basic.ics

vivimage avatar May 15 '24 10:05 vivimage

In this version it's duplicating reccuring exception events with each execution

vivimage avatar May 15 '24 22:05 vivimage

Still testing it. Works like a charm so far.

The only thing, that I'm noticing, as I understand from looking on a calendar, that for reccuring exception events it first create event in an original position (default time from reccuring event) and then moves to a proper time.

The problem, that I'm noticing, that sometimes it is stuck in an original position for a whole time of execution cycle. And with the next execution it moves itself to a proper place.

Don't really know what causing it. Is there a way to make sure event is not stuck in an original position?

Thank you very much!

vivimage avatar May 24 '24 05:05 vivimage

Script from above is updated.

jonas0b1011001 avatar May 25 '24 04:05 jonas0b1011001