diff --git a/src/nlp/totext.ts b/src/nlp/totext.ts index 1e0abac4..4a49e529 100644 --- a/src/nlp/totext.ts +++ b/src/nlp/totext.ts @@ -76,6 +76,9 @@ export default class ToText { const byweekday = !isArray(this.origOptions.byweekday) ? [this.origOptions.byweekday] : this.origOptions.byweekday + if(this.origOptions.bysetpos){ + byweekday.forEach((weekday: Weekday) => weekday.nth(Number(this.origOptions.bysetpos))) + } const days = String(byweekday) this.byweekday = { diff --git a/test/nlp.test.ts b/test/nlp.test.ts index d53c6785..b408dea0 100644 --- a/test/nlp.test.ts +++ b/test/nlp.test.ts @@ -24,6 +24,7 @@ const texts = [ ['Every month on the 3rd Tuesday', 'RRULE:FREQ=MONTHLY;BYDAY=+3TU'], ['Every month on the 3rd last Tuesday', 'RRULE:FREQ=MONTHLY;BYDAY=-3TU'], ['Every month on the last Monday', 'RRULE:FREQ=MONTHLY;BYDAY=-1MO'], + ['Every month on the last Monday', 'RRULE:FREQ=MONTHLY;BYDAY=MO;BYSETPOS=-1'], ['Every month on the 2nd last Friday', 'RRULE:FREQ=MONTHLY;BYDAY=-2FR'], // ['Every week until January 1, 2007', 'RRULE:FREQ=WEEKLY;UNTIL=20070101T080000Z'], ['Every week for 20 times', 'RRULE:FREQ=WEEKLY;COUNT=20']