Skip to content

Commit

Permalink
Fix bug GH-11600: Can't parse time strings which include (narrow) non…
Browse files Browse the repository at this point in the history
…-breaking space characters
  • Loading branch information
derickr committed Jul 11, 2023
1 parent b8fe445 commit a4bdaea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ PHP NEWS

- Date:
. Fixed bug GH-11368 (Date modify returns invalid datetime). (Derick)
. Fixed bug GH-11600 (Can't parse time strings which include (narrow)
non-breaking space characters). (Derick)

- DOM:
. Fixed bug GH-11625 (DOMElement::replaceWith() doesn't replace node with
Expand Down
19 changes: 19 additions & 0 deletions ext/date/tests/bug-gh11600.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
Bug GH-11600: Intl patterns are not parseable DateTime Strings
--INI--
date.timezone=UTC
--FILE--
<?php
$formatter = new IntlDateFormatter('en_US', -1, 3);
$pattern = $formatter->getPattern();

$timeString = $formatter->format(strtotime('2023-07-11 16:02'));

$timestamp = strtotime($timeString);

var_dump($pattern, $timeString, $timestamp);
?>
--EXPECTF--
string(8) "h:mm a"
string(9) "4:02 PM"
int(1689091320)

1 comment on commit a4bdaea

@nielsdos
Copy link
Member

@nielsdos nielsdos commented on a4bdaea Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derickr This test fails on some of the CI targets, and succeeds on others. I believe this is because the Linux ones already use a newer libicu version, while macOS still uses an older one.
Therefore, the output between them differs.
EDIT: also the intl extension line is missing in the extensions section
EDIT 2: I filed #11684, let's see if CI is happy now

Please sign in to comment.