Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement DatePeriod::createFromISO8601String()
- Loading branch information
1 parent
1057cce
commit 9c7c0a0
Showing
10 changed files
with
211 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
ext/date/tests/DatePeriod_createFromISO8601String_static_return.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--TEST-- | ||
Test the static return type of DatePeriod::createFromISO8601String() | ||
--FILE-- | ||
<?php | ||
|
||
class MyDatePeriod extends DatePeriod {} | ||
|
||
var_dump(MyDatePeriod::createFromISO8601String("R4/2012-07-01T00:00:00Z/P7D")); | ||
|
||
try { | ||
MyDatePeriod::createFromISO8601String("R4/2012-07-01T00:/P7D"); | ||
} catch (DateMalformedPeriodStringException $e) { | ||
echo $e->getMessage() . "\n"; | ||
} | ||
|
||
try { | ||
MyDatePeriod::createFromISO8601String("R4/2012-07-01T00:00:00Z"); | ||
} catch (DateMalformedPeriodStringException $e) { | ||
echo $e->getMessage() . "\n"; | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
object(MyDatePeriod)#1 (7) { | ||
["start"]=> | ||
object(DateTime)#2 (3) { | ||
["date"]=> | ||
string(26) "2012-07-01 00:00:00.000000" | ||
["timezone_type"]=> | ||
int(1) | ||
["timezone"]=> | ||
string(6) "+00:00" | ||
} | ||
["current"]=> | ||
NULL | ||
["end"]=> | ||
NULL | ||
["interval"]=> | ||
object(DateInterval)#3 (10) { | ||
["y"]=> | ||
int(0) | ||
["m"]=> | ||
int(0) | ||
["d"]=> | ||
int(7) | ||
["h"]=> | ||
int(0) | ||
["i"]=> | ||
int(0) | ||
["s"]=> | ||
int(0) | ||
["f"]=> | ||
float(0) | ||
["invert"]=> | ||
int(0) | ||
["days"]=> | ||
bool(false) | ||
["from_string"]=> | ||
bool(false) | ||
} | ||
["recurrences"]=> | ||
int(5) | ||
["include_start_date"]=> | ||
bool(true) | ||
["include_end_date"]=> | ||
bool(false) | ||
} | ||
Unknown or bad format (R4/2012-07-01T00:/P7D) | ||
DatePeriod::createFromISO8601String(): ISO interval must contain an interval, "R4/2012-07-01T00:00:00Z" given |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters