Hello Paul,
I'm not sure this is a bug in PHP, tbh, or at least not the way you are
describing it, possibly.
1) I am able to reproduce your results, so let's agree on that :)
2) Your testcase explicitly sets the leniency of the parser to false,
meaning it should strictly parse the date input. You have given a format
of "dd/MM/yyyy" and an input of "21.05.2017", which seems to not match
the format to me. For some reason (unclear to me as of yet), PHP5 (from
14.04) is parsing the incorrectly formatted input regardless of the
leniency value. In contrast, in 16.04.1 with PHP7 (my commentary in [],
newlines manually inserted):
# php -r '$intl = new IntlDateFormatter("en", 2, -1, "Europe/London", 1,
"dd/MM/yyyy");$intl->setLenient(false);echo $intl->parse("21.05.2017");'
[No output, which I think should be expected given the mismatch between input
and format]
# php -r '$intl = new IntlDateFormatter("en", 2, -1, "Europe/London", 1,
"dd/MM/yyyy");$intl->setLenient(true);echo $intl->parse("21.05.2017");'
1495321200
[Turn on leniency and it is parsed]
# php -r '$intl = new IntlDateFormatter("en", 2, -1, "Europe/London", 1,
"dd/MM/yyyy");$intl->setLenient(false);echo $intl->parse("21/05/2017");'
1495321200
[Make input match format and it is parsed, with leniency off]
# php -r '$intl = new IntlDateFormatter("en", 2, -1, "Europe/London", 1,
"dd.MM.yyyy");$intl->setLenient(false);echo $intl->parse("21.05.2017");'
1495321200
[Make format match input and it is parsed, with leniency on]
>From a quick read of the PHP manual, it seems like the proper way to use
parse() is to run it, and then verify the return value before using it.
Doing that, it becomes quite clear that there was an error in parsing.
# php -r '$intl = new IntlDateFormatter("en", 2, -1, "Europe/London", 1,
"dd/MM/yyyy");$intl->setLenient(false);echo $intl->parse("21.05.2017") ==
false; echo $intl->getErrorCode(); echo $intl->getErrorMessage();'
1
9
Date parsing failed: U_PARSE_ERROR
[parse() returned false, an error code was set and an error message is
available, presumably because of my earlier suspicion that the input provided
does not match the format]
For these reasons, I'm going to reject this bug as invalid. Please
reopen if you can point to upstream documentation that indicates this is
incorrect.
** Changed in: php-defaults (Ubuntu)
Status: New => Invalid
** Changed in: php-defaults (Ubuntu)
Assignee: Nish Aravamudan (nacc) => (unassigned)
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1613982
Title:
Date parsing has been fixed in 14.04, but broken in 16.04 again
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php-defaults/+bug/1613982/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs