php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68528 IntlDateFormatter::parse() throws warnings on not parsable date on windows only
Submitted: 2014-11-30 16:22 UTC Modified: 2014-12-17 16:55 UTC
Votes:7
Avg. Score:3.3 ± 0.7
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: mail at cebe dot cc Assigned:
Status: No Feedback Package: intl (PECL)
PHP Version: 5.5.19 OS: Windows
Private report: No CVE-ID: None
 [2014-11-30 16:22 UTC] mail at cebe dot cc
Description:
------------
IntlDateFormatter::parse() throws warnings on not parsable date.
This seems to happen only on Windows but should not happen according to the docs because return value of false is already sufficient indicator for the wrong date.

Originally reported here: https://github.com/yiisoft/yii2/issues/5962

Test script:
---------------
<?php

ini_set('display_errors', 1);
error_reporting(-1);

echo "PHP: " . PHP_VERSION . "\n";
echo "ICU: " . INTL_ICU_VERSION . "\n";

$formatter = new IntlDateFormatter('en_GB', IntlDateFormatter::MEDIUM, IntlDateFormatter::NONE, 'UTC');
// enable strict parsing to avoid getting invalid date values
$formatter->setLenient(false);
var_dump($formatter->parse('20121212'));

$formatter = new IntlDateFormatter('en_GB', IntlDateFormatter::NONE, IntlDateFormatter::NONE, 'UTC', null, 'yyyy.MM.dd');
// enable strict parsing to avoid getting invalid date values
$formatter->setLenient(false);
var_dump($formatter->parse('20121212'));


Expected result:
----------------
According to the docs there should not be a warning but only return value of false. 
http://php.net/manual/en/intldateformatter.parse.php
This is the case for Linux (at least my version).

Actual result:
--------------
Output on Windows:

PHP: 5.5.12 ICU: 51.2 
Warning: IntlDateFormatter::parse(): Date parsing failed in C:\wamp\www\CVCVMProperty\web\date-test.php on line 11
bool(false) 
Warning: IntlDateFormatter::parse(): Date parsing failed in C:\wamp\www\CVCVMProperty\web\date-test.php on line 16
bool(false)

Output on Linux (Ubuntu):

PHP: 5.4.35-1+deb.sury.org~precise+1
ICU: 4.8.1.1
bool(false)
bool(false)



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-12-01 11:03 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2014-12-01 11:03 UTC] ab@php.net
Your comparison is not valid - different PHP and ICU version. Also the ext is from PECL vs core. All that gives just too many unknowns. Btw on Linux even the same PHP version might show some difference depending on ICU version and data used in the distro. So please do a clean comparison and come back.

Thanks.
 [2014-12-17 16:55 UTC] ab@php.net
-Status: Feedback +Status: No Feedback
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 18:01:29 2024 UTC