Last active
December 7, 2015 12:23
-
-
Save tistre/4dcf120dc5b756871f80 to your computer and use it in GitHub Desktop.
Lack of error handling in IntlDateFormatter::localtime()
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
<?php | |
// Correct input value: | |
// $value = 'Wednesday, December 18, 2014 4:05:06 PM PT'; | |
// Wrong input value that I suppose should rather return false: | |
$value = 'XXX'; | |
$formatter = new IntlDateFormatter | |
( | |
'en_US', | |
IntlDateFormatter::FULL, | |
IntlDateFormatter::FULL, | |
'America/Los_Angeles', | |
IntlDateFormatter::GREGORIAN | |
); | |
$localtime = $formatter->localtime($value, $position); | |
var_dump(datefmt_get_error_code($formatter)); // int(0) no matter what | |
var_dump(intl_get_error_code()); // int(0) no matter what | |
var_dump($formatter->format($localtime)); // string(60) "Monday, December 7, 2015 at 4:17:13 AM Pacific Standard Time" | |
var_dump(datefmt_get_error_code($formatter)); // int(0) no matter what | |
var_dump(intl_get_error_code()); // int(0) no matter what |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment