Skip to content

Commit

Permalink
feat: add getter for rrules, exrules and exdates
Browse files Browse the repository at this point in the history
  • Loading branch information
tomquist committed Dec 27, 2023
1 parent 1b7af15 commit 87b7ce2
Show file tree
Hide file tree
Showing 3 changed files with 311 additions and 26 deletions.
11 changes: 9 additions & 2 deletions __test__/daily.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ test('Every Monday in January, for 3 years', () => {
.setByMonth([Month.January])
.setByWeekday([Weekday.Monday])
.setUntil(949327200000);
const set = new RRuleSet(873205200000, 'US/Eastern').addRrule(rrule);
const set = new RRuleSet(873205200000, 'US/Eastern')
.addRrule(rrule)
.addExdate(949327200000);

const asString = set.toString();
const dates = set.all();
Expand All @@ -104,6 +106,11 @@ test('Every Monday in January, for 3 years', () => {
expect(dates).toEqual([
884008800000, 884613600000, 885218400000, 885823200000, 915458400000,
916063200000, 916668000000, 917272800000, 946908000000, 947512800000,
948117600000, 948722400000, 949327200000,
948117600000, 948722400000,
]);
expect(set.getRrules().map((r) => r.toString())).toEqual([
'FREQ=daily;UNTIL=20000131T140000Z;BYMONTH=1;BYHOUR=9;BYMINUTE=0;BYSECOND=0;BYDAY=MO',
]);
expect(set.getExrules().map((r) => r.toString())).toEqual([]);
expect(set.getExdates()).toEqual([949327200000]);
});
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export class RRuleSet {
addExdate(timestamp: number): this
get dtstart(): number
get tzid(): string
getRrules(): RRule[]
getExrules(): RRule[]
getExdates(): number[]
all(limit?: number | undefined | null): number[]
between(after: number, before: number, inclusive?: boolean | undefined | null): number[]
}
Loading

0 comments on commit 87b7ce2

Please sign in to comment.