From ccbc749f65dbc84382e644b825e44a2bab86de35 Mon Sep 17 00:00:00 2001 From: Jeff Bierschbach Date: Sun, 12 Feb 2023 16:29:10 -0600 Subject: [PATCH] Humanreadable gets monthly wrong --- src/RRule.php | 5 +++++ tests/RRuleTest.php | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/RRule.php b/src/RRule.php index b999f7a..1c2b148 100755 --- a/src/RRule.php +++ b/src/RRule.php @@ -2186,6 +2186,11 @@ class RRule implements RRuleInterface $parts['bymonth'] = strtr(self::i18nSelect($i18n['bymonth'], count($tmp)), array( '%{months}' => self::i18nList($tmp, $i18n['and']) )); + + if ($freq_str == 'yearly') { + // if a yearly frequency is being displayed by month, then switch "of the year" text to be monthly + $freq_str = 'monthly'; + } } if (not_empty($this->rule['BYWEEKNO'])) { diff --git a/tests/RRuleTest.php b/tests/RRuleTest.php index b4e8e6e..f29bb4f 100755 --- a/tests/RRuleTest.php +++ b/tests/RRuleTest.php @@ -3204,6 +3204,24 @@ class RRuleTest extends TestCase "daily", "daily" ), + array( + "RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=+2TU", + array('locale' => "en", 'include_start' => false, 'explicit_infinite' => false), + "yearly on the second Tuesday of the month in March", + "yearly on the second Tuesday of the month in March" + ), + array( + "RRULE:FREQ=YEARLY;BYMONTH=3,6,9;BYDAY=+2TU", + array('locale' => "en", 'include_start' => false, 'explicit_infinite' => false), + "yearly on the second Tuesday of the month in March, June and September", + "yearly on the second Tuesday of the month in March, June and September" + ), + array( + "RRULE:FREQ=YEARLY;BYDAY=+6WE", + array('locale' => "en", 'include_start' => false, 'explicit_infinite' => false), + "yearly on the 6th Wednesday of the year", + "yearly on the 6th Wednesday of the year" + ), // with custom_path 'custom_path' => array( "DTSTART:20170202T000000Z\nRRULE:FREQ=YEARLY;UNTIL=20170205T000000Z",