Browse Source

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

migration/RELEASE_1_0_0
Derick Rethans 21 years ago
parent
commit
83bb14d2ff
  1. 5134
      ext/date/lib/parse_date.c
  2. 13
      ext/date/lib/parse_date.re
  3. 13
      ext/date/lib/resource/parse_date.re
  4. 32
      ext/date/tests/bug34771.phpt

5134
ext/date/lib/parse_date.c
File diff suppressed because it is too large
View File

13
ext/date/lib/parse_date.re

@ -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;

13
ext/date/lib/resource/parse_date.re

@ -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;

32
ext/date/tests/bug34771.phpt

@ -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
Loading…
Cancel
Save