Skip to content

Commit

Permalink
EXDATE support (string) (adamgibbons#246)
Browse files Browse the repository at this point in the history
* simple inclusion of EXDATE support in formatEvent() supporting a simple string

Includes a unit test and a detailed entry in the README

* in testing I discovered that MacOS's Calendar App does not seem to understand `EXDATE;VALUE=DATE:YYYYMMDD` input

So much for standards...

So, with that backfiring, I'm reducing the example documentation to only mention the default support for `DATE-TIME`

---------

Co-authored-by: Adam Gibbons <[email protected]>
  • Loading branch information
TiE23 and adamgibbons authored Sep 14, 2023
1 parent f57a791 commit 03d11da
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,22 +213,22 @@ async function handleDownload() {
if (error) {
reject(error)
}

resolve(new File([value], filename, { type: 'text/calendar' }))
})
})
const url = URL.createObjectURL(file);

// trying to assign the file URL to a window could cause cross-site
// issues so this is a workaround using HTML5
const anchor = document.createElement('a');
anchor.href = url;
anchor.download = filename;

document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);

URL.revokeObjectURL(url);
}
```
Expand Down Expand Up @@ -270,7 +270,8 @@ The following properties are accepted:
| productId | Product which created ics, `PRODID` field | `'adamgibbons/ics'`
| uid | Universal unique id for event, produced by default with `nanoid`. **Warning:** This value must be **globally unique**. It is recommended that it follow the [RFC 822 addr-spec](https://www.w3.org/Protocols/rfc822/) (i.e. `localpart@domain`). Including the `@domain` half is a good way to ensure uniqueness. | `'LZfXLFzPPR4NNrgjlWDxn'`
| method | This property defines the iCalendar object method associated with the calendar object. When used in a MIME message entity, the value of this property MUST be the same as the Content-Type "method" parameter value. If either the "METHOD" property or the Content-Type "method" parameter is specified, then the other MUST also be specified. | `PUBLISH`
| recurrenceRule | A recurrence rule, commonly referred to as an RRULE, defines the repeat pattern or rule for to-dos, journal entries and events. If specified, RRULE can be used to compute the recurrence set (the complete set of recurrence instances in a calendar component). You can use a generator like this [one](https://www.textmagic.com/free-tools/rrule-generator) | `FREQ=DAILY`
| recurrenceRule | A recurrence rule, commonly referred to as an RRULE, defines the repeat pattern or rule for to-dos, journal entries and events. If specified, RRULE can be used to compute the recurrence set (the complete set of recurrence instances in a calendar component). You can use a generator like this [one](https://www.textmagic.com/free-tools/rrule-generator). | `FREQ=DAILY`
| exclusionDates| This property defines the list of DATE-TIME exceptions for recurring events, to-dos, journal entries, or time zone definitions. Uses a comma-delimited list of [Date-Time](https://tools.ietf.org/html/rfc5545#section-3.3.5) values. See [EXDATE spec](https://tools.ietf.org/html/rfc5545#section-3.8.5.1).|`'20230620T131500Z,20230621T131500'` (June 20th, 2023 at 1:15pm UTC and June 21st, 2000 at 1:15pm LOCAL)
| sequence | For sending an update for an event (with the same uid), defines the revision sequence number. | `2`
| busyStatus | Used to specify busy status for Microsoft applications, like Outlook. See [Microsoft spec](https://docs.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxcical/cd68eae7-ed65-4dd3-8ea7-ad585c76c736). | `'BUSY'` OR `'FREE'` OR `'TENTATIVE`' OR `'OOF'`
| transp | Used to specify event transparency (does event consume actual time of an individual). Used by Google Calendar to determine if event should change attendees availability to 'Busy' or not. | `'TRANSPARENT'` OR `'OPAQUE'`
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export type EventAttributes = {
uid?: string;
method?: string;
recurrenceRule?: string;
exclusionDates?: string;
sequence?: number;
calName?: string;
classification?: classificationType;
Expand Down
2 changes: 2 additions & 0 deletions src/pipeline/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default function formatEvent(attributes = {}) {
attendees,
alarms,
recurrenceRule,
exclusionDates,
busyStatus,
transp,
classification,
Expand Down Expand Up @@ -89,6 +90,7 @@ export default function formatEvent(attributes = {}) {
})
}
icsFormat += recurrenceRule ? `RRULE:${recurrenceRule}\r\n` : ''
icsFormat += exclusionDates ? `EXDATE:${exclusionDates}\r\n` : ''
icsFormat += duration ? `DURATION:${formatDuration(duration)}\r\n` : ''
if (alarms) {
alarms.map(function (alarm) {
Expand Down
5 changes: 5 additions & 0 deletions test/pipeline/format.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,9 @@ describe('pipeline.formatEvent', () => {

expect(formattedEvent).to.contain('RRULE:FREQ=DAILY')
})
it('writes exception date-time', () => {
const formattedEvent = formatEvent({ exclusionDates: '20000620T010000Z,20000621T010000Z' })

expect(formattedEvent).to.contain('EXDATE:20000620T010000Z,20000621T010000Z')
})
})

0 comments on commit 03d11da

Please sign in to comment.