- Fixed bug #45554 (Inconsistent behavior of the u format char).

This commit is contained in:
Derick Rethans 2009-07-29 15:34:59 +00:00
parent 94ae97b524
commit 923a5de072
3 changed files with 46 additions and 10 deletions

View File

@ -1,8 +1,8 @@
/* Generated by re2c 0.13.5 on Thu Dec 18 15:50:45 2008 */
/* Generated by re2c 0.13.5 on Wed Jul 29 16:31:12 2009 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
| PHP Version 6 |
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
@ -24086,10 +24086,18 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
add_pbf_error(s, "A two digit second could not be found", string, begin);
}
break;
case 'u': /* five digit millisecond, with leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->f = timelib_get_nr((char **) &ptr, 5)) == TIMELIB_UNSET) {
add_pbf_error(s, "A five digit millisecond could not be found", string, begin);
case 'u': /* six digit millisecond */
{
double f;
char *tptr;
TIMELIB_CHECK_NUMBER;
tptr = ptr;
if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || ptr - tptr != 6) {
add_pbf_error(s, "A six digit millisecond could not be found", string, begin);
} else {
s->time->f = (f / 1000000);
}
}
break;
case ' ': /* any sort of whitespace (' ' and \t) */

View File

@ -1943,10 +1943,18 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
add_pbf_error(s, "A two digit second could not be found", string, begin);
}
break;
case 'u': /* five digit millisecond, with leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->f = timelib_get_nr((char **) &ptr, 5)) == TIMELIB_UNSET) {
add_pbf_error(s, "A five digit millisecond could not be found", string, begin);
case 'u': /* six digit millisecond */
{
double f;
char *tptr;
TIMELIB_CHECK_NUMBER;
tptr = ptr;
if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || ptr - tptr != 6) {
add_pbf_error(s, "A six digit millisecond could not be found", string, begin);
} else {
s->time->f = (f / 1000000);
}
}
break;
case ' ': /* any sort of whitespace (' ' and \t) */

View File

@ -0,0 +1,20 @@
--TEST--
Bug #45554 (Inconsistent behavior of the u format char)
--INI--
date.timezone=UTC
--FILE--
<?php
$format = "m-d-Y H:i:s.u T";
$d = date_create_from_format($format, "03-15-2005 12:22:29.000000 PST");
echo $d->format($format), "\n";
$d = date_create_from_format($format, "03-15-2005 12:22:29.001001 PST");
echo $d->format($format), "\n";
$d = date_create_from_format($format, "03-15-2005 12:22:29.0010 PST");
var_dump( $d );
?>
--EXPECT--
03-15-2005 12:22:29.000000 PST
03-15-2005 12:22:29.001000 PST
bool(false)