From ab890aa049b5098a867b693e9e4b67aec52ff772 Mon Sep 17 00:00:00 2001 From: Darren Zhao Date: Fri, 10 Nov 2023 14:45:49 -0500 Subject: [PATCH] Ignore TZID in fully convertible logic. (#528) * TZID is fully convertible. * Add test. --------- Co-authored-by: Darren Zhao --- src/nlp/totext.ts | 2 +- test/nlp.test.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/nlp/totext.ts b/src/nlp/totext.ts index 0a2859cd..e77fd123 100644 --- a/src/nlp/totext.ts +++ b/src/nlp/totext.ts @@ -139,7 +139,7 @@ export default class ToText { if (rrule.origOptions.until && rrule.origOptions.count) return false for (const key in rrule.origOptions) { - if (contains(['dtstart', 'wkst', 'freq'], key)) return true + if (contains(['dtstart', 'tzid', 'wkst', 'freq'], key)) return true if (!contains(ToText.IMPLEMENTED[rrule.options.freq], key)) return false } diff --git a/test/nlp.test.ts b/test/nlp.test.ts index bf8727e2..52173383 100644 --- a/test/nlp.test.ts +++ b/test/nlp.test.ts @@ -32,6 +32,11 @@ const texts = [ ['Every week for 20 times', 'RRULE:FREQ=WEEKLY;COUNT=20'], ] +const toTexts = [ + ...texts, + ['Every week on monday', 'DTSTART;TZID=America/New_York:20220601T000000\nRRULE:INTERVAL=1;FREQ=WEEKLY;BYDAY=MO'], +] + describe('NLP', () => { it('fromText()', function () { texts.forEach(function (item) { @@ -42,7 +47,7 @@ describe('NLP', () => { }) it('toText()', function () { - texts.forEach(function (item) { + toTexts.forEach(function (item) { const text = item[0] const str = item[1] expect(RRule.fromString(str).toText().toLowerCase()).toBe(