php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74597 IntlDateFormatter::parse incorrect behavior on month
Submitted: 2017-05-15 12:37 UTC Modified: 2017-05-16 08:14 UTC
From: shubinmi at gmail dot com Assigned:
Status: Closed Package: intl (PECL)
PHP Version: 5.6.30 OS: CentOS 7.1
Private report: No CVE-ID: None
 [2017-05-15 12:37 UTC] shubinmi at gmail dot com
Description:
------------
IntlDateFormatter::parse has incorrect behavior for mounth. I waiting for error when month is more then 12, but now it returns date of next year.

Test script:
---------------
$formatter = new \IntlDateFormatter('en_US', \IntlDateFormatter::NONE, \IntlDateFormatter::NONE,'UTC', null, 'Y-m-d');
$formatter->setLenient(false);
$parsedDate = $formatter->parse('1981-15-21');
if ($parsedDate === false) {
 echo 'success';
} else {
 echo 'fail';
}

// return "fail"

Expected result:
----------------
false

Actual result:
--------------
int

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-15 14:56 UTC] andrew dot nester dot dev at gmail dot com
Here you can see that `m` stands for minute in an hour, but `M` for month.
http://icu.sourcearchive.com/documentation/4.2/smpdtfmt_8h-source.html

If you will use M in your pattern, you will receive false value.

maybe this behaviour requires some documentation?
 [2017-05-16 08:14 UTC] shubinmi at gmail dot com
-Status: Open +Status: Closed
 [2017-05-16 08:14 UTC] shubinmi at gmail dot com
Thank you! Sorry that took your time. It's my false by inattention.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Nov 28 14:01:23 2020 UTC