1
0
mirror of https://github.com/rlanvin/php-rrule.git synced 2024-11-28 05:24:10 +01:00

Fix #103 createFromRfcString forced uppercase

This commit is contained in:
rlanvin 2022-05-03 15:11:22 +02:00
parent 5ef9eedb5d
commit 2221e8cdac
3 changed files with 19 additions and 4 deletions

View File

@ -2,6 +2,13 @@
## [Unreleased]
## [2.3.2] - 2022-05-03
### Fixed
- Fix timezone (and the entire rule) changed to uppercase if rule was created using `createdFromRfcString` [#103](https://github.com/rlanvin/php-rrule/issues/103)
## [2.3.1] - 2022-04-22
### Fixed
@ -223,7 +230,8 @@
- First release, everything before that was unversioned (`dev-master` was used).
[Unreleased]: https://github.com/rlanvin/php-rrule/compare/v2.3.1...HEAD
[Unreleased]: https://github.com/rlanvin/php-rrule/compare/v2.3.2...HEAD
[2.3.2]: https://github.com/rlanvin/php-rrule/compare/v2.3.1...v2.3.2
[2.3.1]: https://github.com/rlanvin/php-rrule/compare/v2.3.0...v2.3.1
[2.3.0]: https://github.com/rlanvin/php-rrule/compare/v2.2.2...v2.3.0
[2.2.2]: https://github.com/rlanvin/php-rrule/compare/v2.2.1...v2.2.2

View File

@ -670,8 +670,8 @@ class RRule implements RRuleInterface
if (! $force_rset) {
// try to detect if we have a RRULE or a set
$string = strtoupper($string);
$nb_rrule = substr_count($string, 'RRULE');
$upper_string = strtoupper($string);
$nb_rrule = substr_count($upper_string, 'RRULE');
if ($nb_rrule == 0) {
$class = '\RRule\RRule';
}
@ -680,7 +680,7 @@ class RRule implements RRuleInterface
}
else {
$class = '\RRule\RRule';
if (strpos($string, 'EXDATE') !== false || strpos($string, 'RDATE') !== false || strpos($string, 'EXRULE') !== false) {
if (strpos($upper_string, 'EXDATE') !== false || strpos($upper_string, 'RDATE') !== false || strpos($upper_string, 'EXRULE') !== false) {
$class = '\RRule\RSet';
}
}

View File

@ -2520,6 +2520,13 @@ class RRuleTest extends TestCase
$this->assertInstanceOf('\RRule\RSet', $object);
}
public function testCreateFromRfcStringDoesntChangeCase()
{
$str = "DTSTART;TZID=Europe/Paris:20200929T000000\nRRULE:FREQ=DAILY;BYSECOND=0;BYMINUTE=0;BYHOUR=9";
$rule = RRule::createFromRfcString($str);
$this->assertEquals($str, $rule->rfcString());
}
///////////////////////////////////////////////////////////////////////////////
// Timezone