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

Split up recurring event [Request] #439

Open
vivimage opened this issue May 9, 2024 · 20 comments
Open

Split up recurring event [Request] #439

vivimage opened this issue May 9, 2024 · 20 comments

Comments

@vivimage
Copy link

vivimage commented May 9, 2024

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 vivimage changed the title [Request] Split up recurring event [Request] May 9, 2024
@jonas0b1011001
Copy link
Collaborator

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

@vivimage
Copy link
Author

vivimage commented May 9, 2024

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

@jonas0b1011001
Copy link
Collaborator

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

var newEvent = createEvent(event, calendarTz);

@vivimage
Copy link
Author

vivimage commented May 10, 2024

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

@jonas0b1011001
Copy link
Collaborator

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

@vivimage
Copy link
Author

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

@jonas0b1011001
Copy link
Collaborator

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

That makes sense, i'll look into it.

@jonas0b1011001
Copy link
Collaborator

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.

@vivimage
Copy link
Author

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.

@jonas0b1011001
Copy link
Collaborator

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.

@vivimage
Copy link
Author

Any work around that Google discards timezones from recurrence exceptions?

@jonas0b1011001
Copy link
Collaborator

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?

@vivimage
Copy link
Author

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

@vivimage
Copy link
Author

vivimage commented May 15, 2024

@vivimage
Copy link
Author

vivimage commented May 15, 2024

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

@jonas0b1011001
Copy link
Collaborator

@vivimage
Copy link
Author

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!

@jonas0b1011001
Copy link
Collaborator

Script from above is updated.

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

No branches or pull requests

2 participants