Skip to content

Commit

Permalink
feat: Text encoding for BYHOUR, BYMINUTE, BYSECOND
Browse files Browse the repository at this point in the history
  • Loading branch information
plammens committed Apr 28, 2023
1 parent 8653e38 commit 534cba0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 1 addition & 4 deletions lib/src/recurrence_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
10 changes: 10 additions & 0 deletions test/codecs/text/daily_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
);
});
}

0 comments on commit 534cba0

Please sign in to comment.