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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC