adamgibbons / ics

iCalendar (ics) file generator for node.js
ISC License
715 stars 152 forks source link

EXDATE support (string) #246

Closed TiE23 closed 1 year ago

TiE23 commented 1 year ago

Summary

simple inclusion of EXDATE support in formatEvent() supporting a simple string

Includes a unit test and a detailed entry in the README

Who does this help?

This satisfies my own needs, and the needs of those expressed in:

Both contain discussions on how to "hack" a solution: appending EXDATE: to any other string input that doesn't get sanitized by foldLine().

That definitely works. But I thought this was kinda silly. It wouldn't take much to support EXDATE, right?

Attempt using DateArray[]

I spent a little time flirting with the idea of defining excludeDate as an array of DateArray[], but I realized that it would "imply" the allowance of a mix DATE and DATE-TIME input.

Then I started thinking about how I might have it be [number, number, number][] | [number, number, number, number][] | [number, number, number, number, number][]. But that seemed ugly.

And then we'd have to provide more attributes like excludeDateInputType and excludeDateOutputType.

Keep it simple with a string input

I realized that it was far simpler to let the end user to provide the string themself, like is already expected with recurrenceRule.

Note on README Doc example

In testing, using MacOS's Calendar App, I found that support for EXDATE;VALUE=DATE:YYYYMMDD doesn't work. So, as a result of this test revealing that iCal support is spotty, I removed any mention of it in the README.

Testing

I tested EXDATE with MacOS's Calendar App with a recurrence rule calendar.

Screenshot 2023-07-13 at 3 34 41 PM

In this example I had a weekly repeating event on Tuesday at 6pm EDT (-04:00 = 22:00 UTC).

DTSTART:20221101T220000Z
EXDATE:20230711T220000Z,20230718T220000Z

As you can see, the recurring events on July 11 and July 18 are excluded.

(This was really just to make sure that my README examples are correct).

Thanks!

I hope this addition is a decent contribution. I'm proud to say it's not my first to this lovely project (#220)

Please let me know if revisions to the README or anything else is desired. Cheers!