1
0
mirror of https://github.com/rlanvin/php-rrule.git synced 2025-02-21 10:54:14 +01:00

Fix bug in RFC parser generating a invalid timezone

strtoupper() was creating invalid timezone, which would make
humanreadable() fail.
This commit is contained in:
rlanvin 2017-03-29 14:20:00 +01:00
parent b0d91d3b2c
commit 51c7c5c56d
3 changed files with 16 additions and 4 deletions

View File

@ -2,6 +2,12 @@
## [Unreleased] ## [Unreleased]
## [1.4.2] - 2017-03-29
### Fixed
- `humanReadable()` fails if the RRule was created from a RFC string containing the timezone (e.g. `DTSTART;TZID=America/New_York:19970901T090000`)
## [1.4.1] - 2017-02-02 ## [1.4.1] - 2017-02-02
### Fixed ### Fixed

View File

@ -197,6 +197,7 @@ class RRule implements RRuleInterface
{ {
if ( is_string($parts) ) { if ( is_string($parts) ) {
$parts = self::parseRfcString($parts); $parts = self::parseRfcString($parts);
$parts = array_change_key_case($parts, CASE_UPPER);
} }
elseif ( is_array($parts) ) { elseif ( is_array($parts) ) {
$parts = array_change_key_case($parts, CASE_UPPER); $parts = array_change_key_case($parts, CASE_UPPER);
@ -655,7 +656,7 @@ class RRule implements RRuleInterface
{ {
$parts = array(); $parts = array();
$string = strtoupper(trim($string)); $string = trim($string);
$dtstart_type = null; $dtstart_type = null;
$rfc_date_regexp = '/\d{6}(T\d{6})?Z?/'; // a bit loose $rfc_date_regexp = '/\d{6}(T\d{6})?Z?/'; // a bit loose

View File

@ -1804,9 +1804,9 @@ class RRuleTest extends PHPUnit_Framework_TestCase
), ),
// case insensitive // case insensitive
array("dtstart:19970902T090000\nrrule:freq=yearly;count=3", // array("dtstart:19970902T090000\nrrule:freq=yearly;count=3",
array(date_create('1997-09-02 09:00:00'),date_create('1998-09-02 09:00:00'),date_create('1999-09-02 09:00:00')) // array(date_create('1997-09-02 09:00:00'),date_create('1998-09-02 09:00:00'),date_create('1999-09-02 09:00:00'))
), // ),
// empty lines // empty lines
array("\nDTSTART:19970512\nRRULE:FREQ=YEARLY;COUNT=3\n\n", array("\nDTSTART:19970512\nRRULE:FREQ=YEARLY;COUNT=3\n\n",
@ -2580,6 +2580,11 @@ class RRuleTest extends PHPUnit_Framework_TestCase
"DTSTART:20170202T000000Z\nFREQ=DAILY;UNTIL=20170205T000000Z", "DTSTART:20170202T000000Z\nFREQ=DAILY;UNTIL=20170205T000000Z",
"en_IE", "en_IE",
"daily, starting from 02/02/2017, until 05/02/2017" "daily, starting from 02/02/2017, until 05/02/2017"
),
array(
"DTSTART;TZID=America/New_York:19970901T090000\nFREQ=DAILY;UNTIL=20170205T000000Z",
"en_IE",
"daily, starting from 01/09/1997, until 04/02/2017"
) )
); );
} }