- MFH: Fixed bug #34771 (strtotime() fails with 1-12am/pm).

This commit is contained in:
Derick Rethans 2005-10-07 08:09:01 +00:00
parent 595ee08653
commit 969f05a709
5 changed files with 3029 additions and 2892 deletions

1
NEWS
View File

@ -43,6 +43,7 @@ PHP NEWS
- Fixed "make test" to work for phpized extensions. (Hartmut, Jani)
- Fixed failing queries (FALSE returned) with mysqli_query() on 64 bit systems.
(Andrey)
- Fixed bug #34771 (strtotime() fails with 1-12am/pm). (Derick)
- Fixed bug #34723 (array_count_values() strips leading zeroes). (Tony)
- Fixed bug #34678 (__call(), is_callable() and static methods). (Dmitry)
- Fixed bug #34645 (ctype corrupts memory when validating large numbers). (Ilia)

File diff suppressed because it is too large Load Diff

View File

@ -732,6 +732,7 @@ monthroman = "I" | "II" | "III" | "IV" | "V" | "VI" | "VII" | "VIII" | "IX" | "X
monthtext = monthfull | monthabbr | monthroman;
/* Time formats */
timetiny12 = hour12 space? meridian;
timeshort12 = hour12[:.]minutelz space? meridian;
timelong12 = hour12[:.]minute[:.]secondlz space? meridian;
@ -867,15 +868,17 @@ relativetext = (reltextnumber space? reltextunit)+;
return TIMELIB_RELATIVE;
}
timeshort12 | timelong12
timetiny12 | timeshort12 | timelong12
{
DEBUG_OUTPUT("timeshort12 | timelong12");
DEBUG_OUTPUT("timetiny12 | timeshort12 | timelong12");
TIMELIB_INIT;
TIMELIB_HAVE_TIME();
s->time->h = timelib_get_nr((char **) &ptr, 2);
s->time->i = timelib_get_nr((char **) &ptr, 2);
if (*ptr == ':') {
s->time->s = timelib_get_nr((char **) &ptr, 2);
if (*ptr == ':' || *ptr == '.') {
s->time->i = timelib_get_nr((char **) &ptr, 2);
if (*ptr == ':' || *ptr == '.') {
s->time->s = timelib_get_nr((char **) &ptr, 2);
}
}
s->time->h += timelib_meridian((char **) &ptr, s->time->h);
TIMELIB_DEINIT;

View File

@ -732,6 +732,7 @@ monthroman = "I" | "II" | "III" | "IV" | "V" | "VI" | "VII" | "VIII" | "IX" | "X
monthtext = monthfull | monthabbr | monthroman;
/* Time formats */
timetiny12 = hour12 space? meridian;
timeshort12 = hour12[:.]minutelz space? meridian;
timelong12 = hour12[:.]minute[:.]secondlz space? meridian;
@ -867,15 +868,17 @@ relativetext = (reltextnumber space? reltextunit)+;
return TIMELIB_RELATIVE;
}
timeshort12 | timelong12
timetiny12 | timeshort12 | timelong12
{
DEBUG_OUTPUT("timeshort12 | timelong12");
DEBUG_OUTPUT("timetiny12 | timeshort12 | timelong12");
TIMELIB_INIT;
TIMELIB_HAVE_TIME();
s->time->h = timelib_get_nr((char **) &ptr, 2);
s->time->i = timelib_get_nr((char **) &ptr, 2);
if (*ptr == ':') {
s->time->s = timelib_get_nr((char **) &ptr, 2);
if (*ptr == ':' || *ptr == '.') {
s->time->i = timelib_get_nr((char **) &ptr, 2);
if (*ptr == ':' || *ptr == '.') {
s->time->s = timelib_get_nr((char **) &ptr, 2);
}
}
s->time->h += timelib_meridian((char **) &ptr, s->time->h);
TIMELIB_DEINIT;

View File

@ -0,0 +1,32 @@
--TEST--
Bug #34771 (strtotime() fails with 1-12am/pm)
--FILE--
<?php
date_default_timezone_set("UTC");
$tests = array(
'12am', '1am', '1pm',
'12a.m.', '1a.m.', '1p.m.',
'12:00am', '1:00am', '1:00pm',
'12:00a.m.', '1:00a.m.', '1:00p.m.'
);
foreach ($tests as $test) {
$t = strtotime("2005-12-22 ". $test);
printf("%-10s => %s\n", $test, date(DATE_ISO8601, $t));
}
?>
--EXPECT--
12am => 2005-12-22T00:00:00+0000
1am => 2005-12-22T01:00:00+0000
1pm => 2005-12-22T13:00:00+0000
12a.m. => 2005-12-22T00:00:00+0000
1a.m. => 2005-12-22T01:00:00+0000
1p.m. => 2005-12-22T13:00:00+0000
12:00am => 2005-12-22T00:00:00+0000
1:00am => 2005-12-22T01:00:00+0000
1:00pm => 2005-12-22T13:00:00+0000
12:00a.m. => 2005-12-22T00:00:00+0000
1:00a.m. => 2005-12-22T01:00:00+0000
1:00p.m. => 2005-12-22T13:00:00+0000