From 534cba0df5739e9fb684118ffe4eb10ff44f2d95 Mon Sep 17 00:00:00 2001 From: Paolo Lammens Date: Fri, 28 Apr 2023 17:57:03 +0200 Subject: [PATCH] feat: Text encoding for BYHOUR, BYMINUTE, BYSECOND --- lib/src/recurrence_rule.dart | 5 +---- test/codecs/text/daily_test.dart | 10 ++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/src/recurrence_rule.dart b/lib/src/recurrence_rule.dart index 6f29cec..48da989 100644 --- a/lib/src/recurrence_rule.dart +++ b/lib/src/recurrence_rule.dart @@ -363,13 +363,10 @@ class RecurrenceRule { /// Whether this rule can be converted to a human-readable string. /// - /// - Unsupported attributes: [bySeconds], [byMinutes], [byHours] /// - Unsupported frequencies (if any by-parts are specified): /// [Frequency.secondly], [Frequency.hourly], [Frequency.daily] bool get canFullyConvertToText { - if (hasBySeconds || hasByMinutes || hasByHours) { - return false; - } else if (frequency <= Frequency.daily) { + if (frequency <= Frequency.daily) { return true; } else if (hasBySetPositions || hasBySeconds || diff --git a/test/codecs/text/daily_test.dart b/test/codecs/text/daily_test.dart index 382b02f..4c0c1cb 100644 --- a/test/codecs/text/daily_test.dart +++ b/test/codecs/text/daily_test.dart @@ -109,8 +109,18 @@ void main() { ); // Time of day. + testText( 'Daily at 8:30 & 12:30', string: 'RRULE:FREQ=DAILY;BYHOUR=8,12;BYMINUTE=30', ); + + test('canConvertToText is true when byHours is specified', () async { + final rrule = RecurrenceRule(frequency: Frequency.daily, byHours: {8}); + expect(rrule.canFullyConvertToText, isTrue); + expect( + rrule.toText(l10n: await RruleL10nEn.create()), + equals('Daily at 8'), + ); + }); }