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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: shubinmi at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 15 13:01:27 2024 UTC