derick Wed Jul 30 17:48:21 2008 UTC Modified files: /php-src/ext/date php_date.c /php-src/ext/date/lib parse_date.c parse_date.re /php-src/ext/date/tests 012.phpt 013.phpt date_parse_001.phpt Log: - Fixed a bug with the YYYY-MM format not resetting the day correctly. - Fixed a bug in the DateTime->modify() methods, it would not use the advanced relative time strings. - Fixed return values of all the modifying methods, they now properly return the object itself.
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.c?r1=1.202&r2=1.203&diff_format=u Index: php-src/ext/date/php_date.c diff -u php-src/ext/date/php_date.c:1.202 php-src/ext/date/php_date.c:1.203 --- php-src/ext/date/php_date.c:1.202 Wed Jul 30 08:13:02 2008 +++ php-src/ext/date/php_date.c Wed Jul 30 17:48:20 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_date.c,v 1.202 2008/07/30 08:13:02 jani Exp $ */ +/* $Id: php_date.c,v 1.203 2008/07/30 17:48:20 derick Exp $ */ #include "php.h" #include "php_streams.h" @@ -2962,20 +2962,15 @@ DATE_CHECK_INITIALIZED(dateobj->time, DateTime); tmp_time = timelib_strtotime(modify, modify_len, NULL, DATE_TIMEZONEDB); - dateobj->time->relative.y = tmp_time->relative.y; - dateobj->time->relative.m = tmp_time->relative.m; - dateobj->time->relative.d = tmp_time->relative.d; - dateobj->time->relative.h = tmp_time->relative.h; - dateobj->time->relative.i = tmp_time->relative.i; - dateobj->time->relative.s = tmp_time->relative.s; - dateobj->time->relative.weekday = tmp_time->relative.weekday; + memcpy(&dateobj->time->relative, &tmp_time->relative, sizeof(struct timelib_rel_time)); dateobj->time->have_relative = tmp_time->have_relative; - dateobj->time->relative.have_weekday_relative = tmp_time->relative.have_weekday_relative; dateobj->time->sse_uptodate = 0; timelib_time_dtor(tmp_time); timelib_update_ts(dateobj->time, NULL); timelib_update_from_sse(dateobj->time); + + RETURN_ZVAL(object, 1, 0); } /* }}} */ @@ -3115,6 +3110,8 @@ } timelib_set_timezone(dateobj->time, tzobj->tzi.tz); timelib_unixtime2local(dateobj->time, dateobj->time->sse); + + RETURN_ZVAL(object, 1, 0); } /* }}} */ @@ -3171,6 +3168,8 @@ dateobj->time->i = i; dateobj->time->s = s; timelib_update_ts(dateobj->time, NULL); + + RETURN_ZVAL(object, 1, 0); } /* }}} */ @@ -3192,6 +3191,8 @@ dateobj->time->m = m; dateobj->time->d = d; timelib_update_ts(dateobj->time, NULL); + + RETURN_ZVAL(object, 1, 0); } /* }}} */ @@ -3216,6 +3217,8 @@ dateobj->time->have_relative = 1; timelib_update_ts(dateobj->time, NULL); + + RETURN_ZVAL(object, 1, 0); } /* }}} */ @@ -3235,6 +3238,8 @@ DATE_CHECK_INITIALIZED(dateobj->time, DateTime); timelib_unixtime2local(dateobj->time, (timelib_sll)timestamp); timelib_update_ts(dateobj->time, NULL); + + RETURN_ZVAL(object, 1, 0); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/parse_date.c?r1=1.97&r2=1.98&diff_format=u Index: php-src/ext/date/lib/parse_date.c diff -u php-src/ext/date/lib/parse_date.c:1.97 php-src/ext/date/lib/parse_date.c:1.98 --- php-src/ext/date/lib/parse_date.c:1.97 Wed Jul 23 19:52:50 2008 +++ php-src/ext/date/lib/parse_date.c Wed Jul 30 17:48:20 2008 @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Wed Jul 23 21:49:54 2008 */ +/* Generated by re2c 0.13.5 on Wed Jul 30 19:25:10 2008 */ #line 1 "ext/date/lib/parse_date.re" /* +----------------------------------------------------------------------+ @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: parse_date.c,v 1.97 2008/07/23 19:52:50 derick Exp $ */ +/* $Id: parse_date.c,v 1.98 2008/07/30 17:48:20 derick Exp $ */ #include "timelib.h" @@ -982,7 +982,7 @@ } yy3: YYDEBUG(3, *YYCURSOR); -#line 1605 "ext/date/lib/parse_date.re" +#line 1606 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("tzcorrection | tz"); @@ -1306,7 +1306,7 @@ if (yych <= '9') goto yy1343; yy12: YYDEBUG(12, *YYCURSOR); -#line 1700 "ext/date/lib/parse_date.re" +#line 1701 "ext/date/lib/parse_date.re" { add_error(s, "Unexpected character"); goto std; @@ -2334,7 +2334,7 @@ if (yych <= '9') goto yy52; yy47: YYDEBUG(47, *YYCURSOR); -#line 1689 "ext/date/lib/parse_date.re" +#line 1690 "ext/date/lib/parse_date.re" { goto std; } @@ -2347,7 +2347,7 @@ YYDEBUG(49, *YYCURSOR); ++YYCURSOR; YYDEBUG(50, *YYCURSOR); -#line 1694 "ext/date/lib/parse_date.re" +#line 1695 "ext/date/lib/parse_date.re" { s->pos = cursor; s->line++; goto std; @@ -2739,7 +2739,7 @@ if (yych == 's') goto yy71; yy70: YYDEBUG(70, *YYCURSOR); -#line 1673 "ext/date/lib/parse_date.re" +#line 1674 "ext/date/lib/parse_date.re" { timelib_ull i; DEBUG_OUTPUT("relative"); @@ -3507,7 +3507,7 @@ } yy165: YYDEBUG(165, *YYCURSOR); -#line 1536 "ext/date/lib/parse_date.re" +#line 1537 "ext/date/lib/parse_date.re" { const timelib_relunit* relunit; DEBUG_OUTPUT("daytext"); @@ -4001,7 +4001,7 @@ } yy192: YYDEBUG(192, *YYCURSOR); -#line 1595 "ext/date/lib/parse_date.re" +#line 1596 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("monthtext"); TIMELIB_INIT; @@ -4061,7 +4061,7 @@ } yy197: YYDEBUG(197, *YYCURSOR); -#line 1345 "ext/date/lib/parse_date.re" +#line 1346 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("datetextual | datenoyear"); TIMELIB_INIT; @@ -4342,7 +4342,7 @@ } yy221: YYDEBUG(221, *YYCURSOR); -#line 1643 "ext/date/lib/parse_date.re" +#line 1644 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("dateshortwithtimeshort | dateshortwithtimelong | dateshortwithtimelongtz"); @@ -5048,7 +5048,7 @@ YYDEBUG(277, *YYCURSOR); ++YYCURSOR; YYDEBUG(278, *YYCURSOR); -#line 1619 "ext/date/lib/parse_date.re" +#line 1620 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("dateshortwithtimeshort12 | dateshortwithtimelong12"); TIMELIB_INIT; @@ -5244,7 +5244,7 @@ ++YYCURSOR; yy294: YYDEBUG(294, *YYCURSOR); -#line 1319 "ext/date/lib/parse_date.re" +#line 1320 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("datenoday"); TIMELIB_INIT; @@ -6466,7 +6466,7 @@ if (yych <= '9') goto yy364; yy363: YYDEBUG(363, *YYCURSOR); -#line 1459 "ext/date/lib/parse_date.re" +#line 1460 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("pgtextshort"); TIMELIB_INIT; @@ -7062,7 +7062,7 @@ } yy390: YYDEBUG(390, *YYCURSOR); -#line 1515 "ext/date/lib/parse_date.re" +#line 1516 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("ago"); TIMELIB_INIT; @@ -9338,7 +9338,7 @@ } yy473: YYDEBUG(473, *YYCURSOR); -#line 1358 "ext/date/lib/parse_date.re" +#line 1359 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("datenoyearrev"); TIMELIB_INIT; @@ -9979,7 +9979,7 @@ if (yych <= '9') goto yy538; yy532: YYDEBUG(532, *YYCURSOR); -#line 1280 "ext/date/lib/parse_date.re" +#line 1281 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("datefull"); TIMELIB_INIT; @@ -10729,7 +10729,7 @@ YYDEBUG(603, *YYCURSOR); ++YYCURSOR; YYDEBUG(604, *YYCURSOR); -#line 1294 "ext/date/lib/parse_date.re" +#line 1295 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("pointed date YYYY"); TIMELIB_INIT; @@ -10776,7 +10776,7 @@ if (yych <= '9') goto yy602; yy609: YYDEBUG(609, *YYCURSOR); -#line 1306 "ext/date/lib/parse_date.re" +#line 1307 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("pointed date YY"); TIMELIB_INIT; @@ -11429,7 +11429,7 @@ } yy654: YYDEBUG(654, *YYCURSOR); -#line 1267 "ext/date/lib/parse_date.re" +#line 1268 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("gnudateshort"); TIMELIB_INIT; @@ -11794,7 +11794,7 @@ if (yych <= ':') goto yy701; yy698: YYDEBUG(698, *YYCURSOR); -#line 1485 "ext/date/lib/parse_date.re" +#line 1486 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("clf"); @@ -12417,7 +12417,7 @@ YYDEBUG(768, *YYCURSOR); ++YYCURSOR; YYDEBUG(769, *YYCURSOR); -#line 1472 "ext/date/lib/parse_date.re" +#line 1473 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("pgtextreverse"); TIMELIB_INIT; @@ -12567,7 +12567,7 @@ } yy781: YYDEBUG(781, *YYCURSOR); -#line 1506 "ext/date/lib/parse_date.re" +#line 1507 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("year4"); TIMELIB_INIT; @@ -12726,7 +12726,7 @@ } yy791: YYDEBUG(791, *YYCURSOR); -#line 1332 "ext/date/lib/parse_date.re" +#line 1333 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("datenodayrev"); TIMELIB_INIT; @@ -12953,7 +12953,7 @@ if (yych <= '7') goto yy814; yy812: YYDEBUG(812, *YYCURSOR); -#line 1440 "ext/date/lib/parse_date.re" +#line 1441 "ext/date/lib/parse_date.re" { timelib_sll w, d; DEBUG_OUTPUT("isoweek"); @@ -12981,7 +12981,7 @@ YYDEBUG(814, *YYCURSOR); ++YYCURSOR; YYDEBUG(815, *YYCURSOR); -#line 1421 "ext/date/lib/parse_date.re" +#line 1422 "ext/date/lib/parse_date.re" { timelib_sll w, d; DEBUG_OUTPUT("isoweekday"); @@ -13063,7 +13063,7 @@ } yy819: YYDEBUG(819, *YYCURSOR); -#line 1408 "ext/date/lib/parse_date.re" +#line 1409 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("pgydotd"); TIMELIB_INIT; @@ -13178,7 +13178,7 @@ ++YYCURSOR; yy840: YYDEBUG(840, *YYCURSOR); -#line 1382 "ext/date/lib/parse_date.re" +#line 1383 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("xmlrpc | xmlrpcnocolon | soap | wddx | exif"); @@ -13465,7 +13465,7 @@ } yy846: YYDEBUG(846, *YYCURSOR); -#line 1370 "ext/date/lib/parse_date.re" +#line 1371 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("datenocolon"); TIMELIB_INIT; @@ -14403,11 +14403,12 @@ TIMELIB_HAVE_DATE(); s->time->y = timelib_get_nr((char **) &ptr, 4); s->time->m = timelib_get_nr((char **) &ptr, 2); + s->time->d = 1; TIMELIB_PROCESS_YEAR(s->time->y); TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 14411 "ext/date/lib/parse_date.c" +#line 14412 "ext/date/lib/parse_date.c" yy972: YYDEBUG(972, *YYCURSOR); yyaccept = 22; @@ -15438,7 +15439,7 @@ TIMELIB_DEINIT; return TIMELIB_GNU_NOCOLON; } -#line 15442 "ext/date/lib/parse_date.c" +#line 15443 "ext/date/lib/parse_date.c" yy1066: YYDEBUG(1066, *YYCURSOR); yych = *++YYCURSOR; @@ -15549,7 +15550,7 @@ TIMELIB_DEINIT; return TIMELIB_ISO_NOCOLON; } -#line 15553 "ext/date/lib/parse_date.c" +#line 15554 "ext/date/lib/parse_date.c" yy1074: YYDEBUG(1074, *YYCURSOR); yyaccept = 25; @@ -16447,7 +16448,7 @@ } yy1115: YYDEBUG(1115, *YYCURSOR); -#line 1578 "ext/date/lib/parse_date.re" +#line 1579 "ext/date/lib/parse_date.re" { timelib_sll i; int behavior = 0; @@ -16463,7 +16464,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 16467 "ext/date/lib/parse_date.c" +#line 16468 "ext/date/lib/parse_date.c" yy1116: YYDEBUG(1116, *YYCURSOR); ++YYCURSOR; @@ -16535,7 +16536,7 @@ TIMELIB_DEINIT; return TIMELIB_WEEK_DAY_OF_MONTH; } -#line 16539 "ext/date/lib/parse_date.c" +#line 16540 "ext/date/lib/parse_date.c" yy1125: YYDEBUG(1125, *YYCURSOR); yyaccept = 26; @@ -16643,7 +16644,7 @@ } yy1139: YYDEBUG(1139, *YYCURSOR); -#line 1554 "ext/date/lib/parse_date.re" +#line 1555 "ext/date/lib/parse_date.re" { timelib_sll i; int behavior = 0; @@ -16666,7 +16667,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 16670 "ext/date/lib/parse_date.c" +#line 16671 "ext/date/lib/parse_date.c" yy1140: YYDEBUG(1140, *YYCURSOR); yych = *++YYCURSOR; @@ -19106,7 +19107,7 @@ TIMELIB_DEINIT; return TIMELIB_LF_DAY_OF_MONTH; } -#line 19110 "ext/date/lib/parse_date.c" +#line 19111 "ext/date/lib/parse_date.c" yy1290: YYDEBUG(1290, *YYCURSOR); yych = *++YYCURSOR; @@ -20216,7 +20217,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 20220 "ext/date/lib/parse_date.c" +#line 20221 "ext/date/lib/parse_date.c" yy1346: YYDEBUG(1346, *YYCURSOR); yych = *++YYCURSOR; @@ -20663,7 +20664,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 20667 "ext/date/lib/parse_date.c" +#line 20668 "ext/date/lib/parse_date.c" yy1376: YYDEBUG(1376, *YYCURSOR); yych = *++YYCURSOR; @@ -20707,7 +20708,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 20711 "ext/date/lib/parse_date.c" +#line 20712 "ext/date/lib/parse_date.c" yy1379: YYDEBUG(1379, *YYCURSOR); yych = *++YYCURSOR; @@ -22539,7 +22540,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 22543 "ext/date/lib/parse_date.c" +#line 22544 "ext/date/lib/parse_date.c" yy1459: YYDEBUG(1459, *YYCURSOR); yych = *++YYCURSOR; @@ -22689,7 +22690,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 22693 "ext/date/lib/parse_date.c" +#line 22694 "ext/date/lib/parse_date.c" yy1467: YYDEBUG(1467, *YYCURSOR); yyaccept = 0; @@ -23180,7 +23181,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 23184 "ext/date/lib/parse_date.c" +#line 23185 "ext/date/lib/parse_date.c" yy1490: YYDEBUG(1490, *YYCURSOR); yyaccept = 0; @@ -23326,7 +23327,7 @@ goto yy1489; } } -#line 1704 "ext/date/lib/parse_date.re" +#line 1705 "ext/date/lib/parse_date.re" } http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/parse_date.re?r1=1.88&r2=1.89&diff_format=u Index: php-src/ext/date/lib/parse_date.re diff -u php-src/ext/date/lib/parse_date.re:1.88 php-src/ext/date/lib/parse_date.re:1.89 --- php-src/ext/date/lib/parse_date.re:1.88 Wed Jul 23 19:52:51 2008 +++ php-src/ext/date/lib/parse_date.re Wed Jul 30 17:48:20 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: parse_date.re,v 1.88 2008/07/23 19:52:51 derick Exp $ */ +/* $Id: parse_date.re,v 1.89 2008/07/30 17:48:20 derick Exp $ */ #include "timelib.h" @@ -1258,6 +1258,7 @@ TIMELIB_HAVE_DATE(); s->time->y = timelib_get_nr((char **) &ptr, 4); s->time->m = timelib_get_nr((char **) &ptr, 2); + s->time->d = 1; TIMELIB_PROCESS_YEAR(s->time->y); TIMELIB_DEINIT; return TIMELIB_ISO_DATE; http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/012.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/date/tests/012.phpt diff -u php-src/ext/date/tests/012.phpt:1.2 php-src/ext/date/tests/012.phpt:1.3 --- php-src/ext/date/tests/012.phpt:1.2 Tue May 27 18:16:00 2008 +++ php-src/ext/date/tests/012.phpt Wed Jul 30 17:48:21 2008 @@ -20,15 +20,36 @@ echo "Done\n"; ?> --EXPECTF-- -NULL +object(DateTime)#1 (3) { + [u"date"]=> + unicode(19) "2006-01-23 00:00:00" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(3) "UTC" +} unicode(19) "2006/01/23 00:00:00" Warning: date_isodate_set() expects at least 3 parameters, 2 given in %s on line %d bool(false) unicode(19) "2006/01/23 00:00:00" -NULL +object(DateTime)#1 (3) { + [u"date"]=> + unicode(19) "2006-01-30 00:00:00" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(3) "UTC" +} unicode(19) "2006/01/30 00:00:00" -NULL +object(DateTime)#1 (3) { + [u"date"]=> + unicode(19) "2007-12-10 00:00:00" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(3) "UTC" +} unicode(19) "2007/12/10 00:00:00" Warning: date_isodate_set() expects at most 4 parameters, 5 given in %s on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/013.phpt?r1=1.4&r2=1.5&diff_format=u Index: php-src/ext/date/tests/013.phpt diff -u php-src/ext/date/tests/013.phpt:1.4 php-src/ext/date/tests/013.phpt:1.5 --- php-src/ext/date/tests/013.phpt:1.4 Sat Jun 7 20:33:35 2008 +++ php-src/ext/date/tests/013.phpt Wed Jul 30 17:48:21 2008 @@ -37,8 +37,22 @@ Warning: date_date_set() expects exactly 4 parameters, 3 given in %s on line %d bool(false) unicode(19) "2006.12.12 00:00:00" -NULL +object(DateTime)#1 (3) { + [u"date"]=> + unicode(19) "2006-02-15 00:00:00" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(3) "UTC" +} unicode(19) "2006.02.15 00:00:00" -NULL +object(DateTime)#1 (3) { + [u"date"]=> + unicode(19) "2008-01-29 00:00:00" + [u"timezone_type"]=> + int(3) + [u"timezone"]=> + unicode(3) "UTC" +} unicode(19) "2008.01.29 00:00:00" Done http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/date_parse_001.phpt?r1=1.6&r2=1.7&diff_format=u Index: php-src/ext/date/tests/date_parse_001.phpt diff -u php-src/ext/date/tests/date_parse_001.phpt:1.6 php-src/ext/date/tests/date_parse_001.phpt:1.7 --- php-src/ext/date/tests/date_parse_001.phpt:1.6 Tue Jul 29 12:17:04 2008 +++ php-src/ext/date/tests/date_parse_001.phpt Wed Jul 30 17:48:21 2008 @@ -79,7 +79,7 @@ [u"month"]=> int(12) [u"day"]=> - bool(false) + int(1) [u"hour"]=> bool(false) [u"minute"]=> @@ -89,11 +89,9 @@ [u"fraction"]=> bool(false) [u"warning_count"]=> - int(1) + int(0) [u"warnings"]=> - array(1) { - [12]=> - unicode(27) "The parsed date was invalid" + array(0) { } [u"error_count"]=> int(1) @@ -175,7 +173,7 @@ [u"month"]=> int(3) [u"day"]=> - bool(false) + int(1) [u"hour"]=> bool(false) [u"minute"]=> @@ -185,11 +183,9 @@ [u"fraction"]=> bool(false) [u"warning_count"]=> - int(1) + int(0) [u"warnings"]=> - array(1) { - [8]=> - unicode(27) "The parsed date was invalid" + array(0) { } [u"error_count"]=> int(0)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php