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

Add a multi-value with addPropertyWithValue #436

Closed
radarfox opened this issue Apr 15, 2020 · 2 comments
Closed

Add a multi-value with addPropertyWithValue #436

radarfox opened this issue Apr 15, 2020 · 2 comments

Comments

@radarfox
Copy link

Is it possible to add multiple values by this method? For example, to EXDATE where you can add a comma delimited list of dates. I would expect something like this to work:

const vevent = new ICAL.Component('vevent');
vevent.addPropertyWithValue([new ICAL.Time({year: 2020}), new ICAL.Time({year: 2021})]);

But this will produce the following error:

TypeError: property[0].toUpperCase is not a function

I ended up using the lower-level method:

function createExdateProperty (times) {
  const strings = times.map((time) => time.toICALString());
  return new this.ICAL.Property(['exdate', {}, 'date-time', ...strings]);
}

Maybe would you consider adding something like addPropertyWithMultiValue, or allow to pass an array to addPropertyWithValue, for the multi-value components?

@kewisch
Copy link
Owner

kewisch commented Apr 15, 2024

Not possible with that function. if times are ICAL.Property already you want:

const vevent = new ICAL.Component('vevent');
const exdate = new ICAL.Property('exdate');
exdate.setValues(times);
vevent.addProperty(exdate);

@kewisch
Copy link
Owner

kewisch commented Apr 15, 2024

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