Browse Source

Fixed bug #38229 (strtotime() does not parse YYYY-MM format).

PECL_OPENSSL
Ilia Alshanetsky 20 years ago
parent
commit
af48ecfc87
  1. 1
      NEWS
  2. 35381
      ext/date/lib/parse_date.c
  3. 13
      ext/date/lib/parse_date.re
  4. 13
      ext/date/tests/bug38229.phpt

1
NEWS

@ -16,6 +16,7 @@ PHP NEWS
compatibility issue). (Patch: scott dot moynes+php at gmail dot com)
- Fixed bug #38234 (Exception in __clone makes memory leak). (Dmitry, Nuno)
- Fixed bug #38229 (strtotime() does not parse YYYY-MM format). (Ilia)
- Fixed bug #38220 (Crash on some object operations). (Dmitry)
- Fixed bug #38217 (ReflectionClass::newInstanceArgs() tries to allocate too
much memory). (Tony)

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

13
ext/date/lib/parse_date.re

@ -829,6 +829,7 @@ americanshort = month "/" day;
american = month "/" day "/" year;
iso8601dateslash = year4 "/" monthlz "/" daylz "/"?;
dateslash = year4 "/" month "/" day;
gnudateshorter = year4 "-" month;
gnudateshort = year "-" month "-" day;
iso8601date = year4 "-" monthlz "-" daylz;
pointeddate = day [.\t-] month [.-] year;
@ -1094,6 +1095,18 @@ relativetext = reltextnumber space reltextunit;
return TIMELIB_ISO_DATE;
}
gnudateshorter
{
DEBUG_OUTPUT("gnudateshorter");
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
s->time->y = timelib_get_nr((char **) &ptr, 4);
s->time->m = timelib_get_nr((char **) &ptr, 2);
TIMELIB_PROCESS_YEAR(s->time->y);
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
gnudateshort
{
DEBUG_OUTPUT("gnudateshort");

13
ext/date/tests/bug38229.phpt

@ -0,0 +1,13 @@
--TEST--
Bug #38229 (strtotime() does not parse YYYY-MM)
--FILE--
<?php
date_default_timezone_set("GMT");
echo date("Y-m", strtotime('2006-1'))."\n";
echo date("Y-m", strtotime('2006-03'))."\n";
echo date("Y-m", strtotime('2006-12'))."\n";
?>
--EXPECT--
2006-01
2006-03
2006-12
Loading…
Cancel
Save