From d095243b99e75f02c0d450594f671aa60e82c324 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Wed, 19 Oct 2005 21:11:15 +0000 Subject: [PATCH] - MF51: Fixed bug #34874 and #33546 (Problems with lone daynames). --- ext/date/lib/parse_date.c | 184 ++++++++++++++-------------- ext/date/lib/parse_date.re | 24 ++-- ext/date/lib/resource/parse_date.re | 24 ++-- ext/date/lib/timelib.c | 2 +- ext/date/lib/timelib_structs.h | 1 + ext/date/lib/tm2unixtime.c | 2 +- ext/date/tests/bug20382-2.phpt | 2 +- ext/date/tests/bug33414-1.phpt | 48 ++++---- ext/date/tests/bug33414-2.phpt | 18 +-- ext/date/tests/bug33415-1.phpt | 4 +- ext/date/tests/bug33415-2.phpt | 46 +++---- 11 files changed, 184 insertions(+), 171 deletions(-) diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c index 8c028a5e00..0882efd578 100644 --- a/ext/date/lib/parse_date.c +++ b/ext/date/lib/parse_date.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.9.10.dev on Sat Oct 8 16:29:08 2005 */ +/* Generated by re2c 0.9.10.dev on Wed Oct 19 22:39:08 2005 */ #line 1 "resource/parse_date.re" /* +----------------------------------------------------------------------+ @@ -102,7 +102,7 @@ typedef unsigned char uchar; #define TIMELIB_UNHAVE_TIME() { s->time->have_time = 0; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; } #define TIMELIB_HAVE_DATE() { if (s->time->have_date) { return TIMELIB_ERROR; } else { s->time->have_date = 1; } } #define TIMELIB_UNHAVE_DATE() { s->time->have_date = 0; s->time->d = 0; s->time->m = 0; s->time->y = 0; } -#define TIMELIB_HAVE_RELATIVE() { s->time->have_relative = 1; } +#define TIMELIB_HAVE_RELATIVE() { s->time->have_relative = 1; s->time->relative.weekday_behavior = 0; } #define TIMELIB_HAVE_WEEKDAY_RELATIVE() { s->time->have_weekday_relative = 1; } #define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return TIMELIB_ERROR; } else { s->time.have_zone = 1; } } @@ -224,8 +224,8 @@ static timelib_lookup_table const timelib_reltext_lookup[] = { { "twelfth", 0, 12 }, { "last", 0, -1 }, { "previous", 0, -1 }, - { "this", 0, 0 }, - { NULL, 0, 0 } + { "this", 1, 0 }, + { NULL, 1, 0 } }; /* The month table. */ @@ -441,7 +441,7 @@ static long timelib_parse_tz_cor(char **ptr) return 0; } -static timelib_sll timelib_lookup_relative_text(char **ptr) +static timelib_sll timelib_lookup_relative_text(char **ptr, int *behavior) { char *word; char *begin = *ptr, *end; @@ -458,6 +458,7 @@ static timelib_sll timelib_lookup_relative_text(char **ptr) for (tp = timelib_reltext_lookup; tp->name; tp++) { if (strcasecmp(word, tp->name) == 0) { value = tp->value; + *behavior = tp->type; } } @@ -465,12 +466,12 @@ static timelib_sll timelib_lookup_relative_text(char **ptr) return value; } -static timelib_sll timelib_get_relative_text(char **ptr) +static timelib_sll timelib_get_relative_text(char **ptr, int *behavior) { while (**ptr == ' ' || **ptr == '-' || **ptr == '/') { ++*ptr; } - return timelib_lookup_relative_text(ptr); + return timelib_lookup_relative_text(ptr, behavior); } static long timelib_lookup_month(char **ptr) @@ -536,7 +537,7 @@ static const timelib_relunit* timelib_lookup_relunit(char **ptr) return value; } -static void timelib_set_relative(char **ptr, timelib_sll amount, Scanner *s) +static void timelib_set_relative(char **ptr, timelib_sll amount, int behavior, Scanner *s) { const timelib_relunit* relunit; @@ -554,6 +555,7 @@ static void timelib_set_relative(char **ptr, timelib_sll amount, Scanner *s) TIMELIB_UNHAVE_TIME(); s->time->relative.d += (amount > 0 ? amount - 1 : amount) * 7; s->time->relative.weekday = relunit->multiplier; + s->time->relative.weekday_behavior = behavior; break; } } @@ -693,7 +695,7 @@ static int scan(Scanner *s) std: s->tok = cursor; s->len = 0; -#line 800 "resource/parse_date.re" +#line 802 "resource/parse_date.re" { @@ -732,7 +734,7 @@ std: 0, 0, 0, 0, 0, 0, 0, 0, }; -#line 736 "" +#line 738 "" { YYCTYPE yych; unsigned int yyaccept; @@ -817,7 +819,7 @@ yy2: yy3: YYDEBUG(3, *YYCURSOR); -#line 1296 "resource/parse_date.re" +#line 1300 "resource/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("tzcorrection | tz"); @@ -827,7 +829,7 @@ yy3: TIMELIB_DEINIT; return TIMELIB_TIMEZONE; } -#line 824 "" +#line 826 "" yy4: YYDEBUG(4, *YYCURSOR); yych = *++YYCURSOR; @@ -937,13 +939,13 @@ yy7: yy8: YYDEBUG(8, *YYCURSOR); -#line 1362 "resource/parse_date.re" +#line 1366 "resource/parse_date.re" { /* printf("unexpected character: #%d, %c ", *s->tok, *s->tok); */ s->errors++; goto std; } -#line 929 "" +#line 931 "" yy9: YYDEBUG(9, *YYCURSOR); yyaccept = 0; @@ -1852,11 +1854,11 @@ yy43: yy44: YYDEBUG(44, *YYCURSOR); -#line 1351 "resource/parse_date.re" +#line 1355 "resource/parse_date.re" { goto std; } -#line 1765 "" +#line 1767 "" yy45: YYDEBUG(45, *YYCURSOR); ++YYCURSOR; @@ -1864,12 +1866,12 @@ yy45: yy46: YYDEBUG(46, *YYCURSOR); -#line 1356 "resource/parse_date.re" +#line 1360 "resource/parse_date.re" { s->pos = cursor; s->line++; goto std; } -#line 1774 "" +#line 1776 "" yy47: YYDEBUG(47, *YYCURSOR); yych = *++YYCURSOR; @@ -2327,7 +2329,7 @@ yy84: yy85: YYDEBUG(85, *YYCURSOR); -#line 1335 "resource/parse_date.re" +#line 1339 "resource/parse_date.re" { timelib_ull i; DEBUG_OUTPUT("relative"); @@ -2337,12 +2339,12 @@ yy85: while(*ptr) { i = timelib_get_unsigned_nr((char **) &ptr, 24); timelib_eat_spaces((char **) &ptr); - timelib_set_relative((char **) &ptr, i, s); + timelib_set_relative((char **) &ptr, i, 0, s); } TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 2164 "" +#line 2166 "" yy86: YYDEBUG(86, *YYCURSOR); ++YYCURSOR; @@ -3035,12 +3037,12 @@ yy150: yy151: YYDEBUG(151, *YYCURSOR); -#line 1290 "resource/parse_date.re" +#line 1294 "resource/parse_date.re" { DEBUG_OUTPUT("dayabbr"); goto std; } -#line 2728 "" +#line 2730 "" yy152: YYDEBUG(152, *YYCURSOR); yyaccept = 1; @@ -3079,7 +3081,7 @@ yy157: yy158: YYDEBUG(158, *YYCURSOR); -#line 1274 "resource/parse_date.re" +#line 1277 "resource/parse_date.re" { const timelib_relunit* relunit; DEBUG_OUTPUT("dayfull"); @@ -3090,11 +3092,12 @@ yy158: relunit = timelib_lookup_relunit((char**) &ptr); s->time->relative.weekday = relunit->multiplier; + s->time->relative.weekday_behavior = 1; TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 2768 "" +#line 2771 "" yy159: YYDEBUG(159, *YYCURSOR); yyaccept = 1; @@ -3463,22 +3466,23 @@ yy189: yy190: YYDEBUG(190, *YYCURSOR); -#line 1258 "resource/parse_date.re" +#line 1260 "resource/parse_date.re" { timelib_sll i; + int behavior; DEBUG_OUTPUT("relativetext"); TIMELIB_INIT; TIMELIB_HAVE_RELATIVE(); while(*ptr) { - i = timelib_get_relative_text((char **) &ptr); + i = timelib_get_relative_text((char **) &ptr, &behavior); timelib_eat_spaces((char **) &ptr); - timelib_set_relative((char **) &ptr, i, s); + timelib_set_relative((char **) &ptr, i, behavior, s); } TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 3086 "" +#line 3090 "" yy191: YYDEBUG(191, *YYCURSOR); ++YYCURSOR; @@ -9108,7 +9112,7 @@ yy508: yy509: YYDEBUG(509, *YYCURSOR); -#line 1080 "resource/parse_date.re" +#line 1082 "resource/parse_date.re" { DEBUG_OUTPUT("datetextual | datenoyear"); TIMELIB_INIT; @@ -9120,7 +9124,7 @@ yy509: TIMELIB_DEINIT; return TIMELIB_DATE_TEXT; } -#line 8079 "" +#line 8083 "" yy510: YYDEBUG(510, *YYCURSOR); yych = *++YYCURSOR; @@ -9280,7 +9284,7 @@ yy526: yy527: YYDEBUG(527, *YYCURSOR); -#line 1307 "resource/parse_date.re" +#line 1311 "resource/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("dateshortwithtimeshort | dateshortwithtimelong | dateshortwithtimelongtz"); @@ -9307,7 +9311,7 @@ yy527: TIMELIB_DEINIT; return TIMELIB_SHORTDATE_WITH_TIME; } -#line 8230 "" +#line 8234 "" yy528: YYDEBUG(528, *YYCURSOR); yyaccept = 7; @@ -9620,7 +9624,7 @@ yy561: yy562: YYDEBUG(562, *YYCURSOR); -#line 1054 "resource/parse_date.re" +#line 1056 "resource/parse_date.re" { DEBUG_OUTPUT("datenoday"); TIMELIB_INIT; @@ -9632,7 +9636,7 @@ yy562: TIMELIB_DEINIT; return TIMELIB_DATE_NO_DAY; } -#line 8485 "" +#line 8489 "" yy563: YYDEBUG(563, *YYCURSOR); yyaccept = 6; @@ -9932,7 +9936,7 @@ yy587: yy588: YYDEBUG(588, *YYCURSOR); -#line 1189 "resource/parse_date.re" +#line 1191 "resource/parse_date.re" { DEBUG_OUTPUT("pgtextshort"); TIMELIB_INIT; @@ -9944,7 +9948,7 @@ yy588: TIMELIB_DEINIT; return TIMELIB_PG_TEXT; } -#line 8744 "" +#line 8748 "" yy589: YYDEBUG(589, *YYCURSOR); yych = *++YYCURSOR; @@ -11448,7 +11452,7 @@ yy683: yy684: YYDEBUG(684, *YYCURSOR); -#line 1243 "resource/parse_date.re" +#line 1245 "resource/parse_date.re" { DEBUG_OUTPUT("ago"); TIMELIB_INIT; @@ -11462,7 +11466,7 @@ yy684: TIMELIB_DEINIT; return TIMELIB_AGO; } -#line 10069 "" +#line 10073 "" yy685: YYDEBUG(685, *YYCURSOR); yyaccept = 1; @@ -13397,7 +13401,7 @@ yy787: yy788: YYDEBUG(788, *YYCURSOR); -#line 1093 "resource/parse_date.re" +#line 1095 "resource/parse_date.re" { DEBUG_OUTPUT("datenoyearrev"); TIMELIB_INIT; @@ -13407,7 +13411,7 @@ yy788: TIMELIB_DEINIT; return TIMELIB_DATE_TEXT; } -#line 11802 "" +#line 11806 "" yy789: YYDEBUG(789, *YYCURSOR); yyaccept = 10; @@ -13517,7 +13521,7 @@ yy798: yy799: YYDEBUG(799, *YYCURSOR); -#line 884 "resource/parse_date.re" +#line 886 "resource/parse_date.re" { DEBUG_OUTPUT("timetiny12 | timeshort12 | timelong12"); TIMELIB_INIT; @@ -13533,7 +13537,7 @@ yy799: TIMELIB_DEINIT; return TIMELIB_TIME12; } -#line 11906 "" +#line 11910 "" yy800: YYDEBUG(800, *YYCURSOR); yych = *++YYCURSOR; @@ -13553,7 +13557,7 @@ yy801: yy802: YYDEBUG(802, *YYCURSOR); -#line 901 "resource/parse_date.re" +#line 903 "resource/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("timeshort24 | timelong24 | iso8601long"); @@ -13576,7 +13580,7 @@ yy802: TIMELIB_DEINIT; return TIMELIB_TIME24_WITH_ZONE; } -#line 11943 "" +#line 11947 "" yy803: YYDEBUG(803, *YYCURSOR); yyaccept = 11; @@ -13819,7 +13823,7 @@ yy827: yy828: YYDEBUG(828, *YYCURSOR); -#line 1028 "resource/parse_date.re" +#line 1030 "resource/parse_date.re" { DEBUG_OUTPUT("datefull"); TIMELIB_INIT; @@ -13831,7 +13835,7 @@ yy828: TIMELIB_DEINIT; return TIMELIB_DATE_FULL; } -#line 12146 "" +#line 12150 "" yy829: YYDEBUG(829, *YYCURSOR); yych = *++YYCURSOR; @@ -14466,7 +14470,7 @@ yy896: yy897: YYDEBUG(897, *YYCURSOR); -#line 1041 "resource/parse_date.re" +#line 1043 "resource/parse_date.re" { DEBUG_OUTPUT("pointed date"); TIMELIB_INIT; @@ -14478,7 +14482,7 @@ yy897: TIMELIB_DEINIT; return TIMELIB_DATE_FULL_POINTED; } -#line 12655 "" +#line 12659 "" yy898: YYDEBUG(898, *YYCURSOR); yych = *++YYCURSOR; @@ -15046,7 +15050,7 @@ yy942: yy943: YYDEBUG(943, *YYCURSOR); -#line 1015 "resource/parse_date.re" +#line 1017 "resource/parse_date.re" { DEBUG_OUTPUT("gnudateshort"); TIMELIB_INIT; @@ -15058,7 +15062,7 @@ yy943: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 13143 "" +#line 13147 "" yy944: YYDEBUG(944, *YYCURSOR); yych = *++YYCURSOR; @@ -15080,7 +15084,7 @@ yy946: yy947: YYDEBUG(947, *YYCURSOR); -#line 988 "resource/parse_date.re" +#line 990 "resource/parse_date.re" { DEBUG_OUTPUT("americanshort | american"); TIMELIB_INIT; @@ -15094,7 +15098,7 @@ yy947: TIMELIB_DEINIT; return TIMELIB_AMERICAN; } -#line 13171 "" +#line 13175 "" yy948: YYDEBUG(948, *YYCURSOR); yyaccept = 12; @@ -15316,7 +15320,7 @@ yy979: yy980: YYDEBUG(980, *YYCURSOR); -#line 1215 "resource/parse_date.re" +#line 1217 "resource/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("clf"); @@ -15334,7 +15338,7 @@ yy980: TIMELIB_DEINIT; return TIMELIB_CLF; } -#line 13345 "" +#line 13349 "" yy981: YYDEBUG(981, *YYCURSOR); yyaccept = 13; @@ -15643,7 +15647,7 @@ yy1019: yy1020: YYDEBUG(1020, *YYCURSOR); -#line 1202 "resource/parse_date.re" +#line 1204 "resource/parse_date.re" { DEBUG_OUTPUT("pgtextreverse"); TIMELIB_INIT; @@ -15655,7 +15659,7 @@ yy1020: TIMELIB_DEINIT; return TIMELIB_PG_TEXT; } -#line 13585 "" +#line 13589 "" yy1021: YYDEBUG(1021, *YYCURSOR); yych = *++YYCURSOR; @@ -15788,7 +15792,7 @@ yy1031: yy1032: YYDEBUG(1032, *YYCURSOR); -#line 1234 "resource/parse_date.re" +#line 1236 "resource/parse_date.re" { DEBUG_OUTPUT("year4"); TIMELIB_INIT; @@ -15796,7 +15800,7 @@ yy1032: TIMELIB_DEINIT; return TIMELIB_CLF; } -#line 13701 "" +#line 13705 "" yy1033: YYDEBUG(1033, *YYCURSOR); yych = *++YYCURSOR; @@ -15932,7 +15936,7 @@ yy1040: yy1041: YYDEBUG(1041, *YYCURSOR); -#line 1067 "resource/parse_date.re" +#line 1069 "resource/parse_date.re" { DEBUG_OUTPUT("datenodayrev"); TIMELIB_INIT; @@ -15944,7 +15948,7 @@ yy1041: TIMELIB_DEINIT; return TIMELIB_DATE_NO_DAY; } -#line 13828 "" +#line 13832 "" yy1042: YYDEBUG(1042, *YYCURSOR); yych = *++YYCURSOR; @@ -16153,7 +16157,7 @@ yy1060: yy1061: YYDEBUG(1061, *YYCURSOR); -#line 1170 "resource/parse_date.re" +#line 1172 "resource/parse_date.re" { timelib_sll w, d; DEBUG_OUTPUT("isoweek"); @@ -16171,7 +16175,7 @@ yy1061: TIMELIB_DEINIT; return TIMELIB_ISO_WEEK; } -#line 14015 "" +#line 14019 "" yy1062: YYDEBUG(1062, *YYCURSOR); ++YYCURSOR; @@ -16179,7 +16183,7 @@ yy1062: yy1063: YYDEBUG(1063, *YYCURSOR); -#line 1151 "resource/parse_date.re" +#line 1153 "resource/parse_date.re" { timelib_sll w, d; DEBUG_OUTPUT("isoweekday"); @@ -16197,7 +16201,7 @@ yy1063: TIMELIB_DEINIT; return TIMELIB_ISO_WEEK; } -#line 14037 "" +#line 14041 "" yy1064: YYDEBUG(1064, *YYCURSOR); yych = *++YYCURSOR; @@ -16266,7 +16270,7 @@ yy1066: yy1067: YYDEBUG(1067, *YYCURSOR); -#line 1138 "resource/parse_date.re" +#line 1140 "resource/parse_date.re" { DEBUG_OUTPUT("pgydotd"); TIMELIB_INIT; @@ -16278,7 +16282,7 @@ yy1067: TIMELIB_DEINIT; return TIMELIB_PG_YEARDAY; } -#line 14110 "" +#line 14114 "" yy1068: YYDEBUG(1068, *YYCURSOR); yych = *++YYCURSOR; @@ -16393,7 +16397,7 @@ yy1073: yy1074: YYDEBUG(1074, *YYCURSOR); -#line 1104 "resource/parse_date.re" +#line 1106 "resource/parse_date.re" { DEBUG_OUTPUT("datenocolon"); TIMELIB_INIT; @@ -16404,7 +16408,7 @@ yy1074: TIMELIB_DEINIT; return TIMELIB_DATE_NOCOLON; } -#line 14218 "" +#line 14222 "" yy1075: YYDEBUG(1075, *YYCURSOR); yych = *++YYCURSOR; @@ -16502,7 +16506,7 @@ yy1084: yy1085: YYDEBUG(1085, *YYCURSOR); -#line 1116 "resource/parse_date.re" +#line 1118 "resource/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("xmlrpc | xmlrpcnocolon | soap | wddx"); @@ -16523,7 +16527,7 @@ yy1085: TIMELIB_DEINIT; return TIMELIB_XMLRPC_SOAP; } -#line 14315 "" +#line 14319 "" yy1086: YYDEBUG(1086, *YYCURSOR); yych = *++YYCURSOR; @@ -17126,7 +17130,7 @@ yy1175: yy1176: YYDEBUG(1176, *YYCURSOR); -#line 1003 "resource/parse_date.re" +#line 1005 "resource/parse_date.re" { DEBUG_OUTPUT("iso8601date | iso8601dateslash | dateslash"); TIMELIB_INIT; @@ -17137,7 +17141,7 @@ yy1176: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 14747 "" +#line 14751 "" yy1177: YYDEBUG(1177, *YYCURSOR); yych = *++YYCURSOR; @@ -17952,7 +17956,7 @@ yy1268: yy1269: YYDEBUG(1269, *YYCURSOR); -#line 925 "resource/parse_date.re" +#line 927 "resource/parse_date.re" { DEBUG_OUTPUT("gnunocolon"); TIMELIB_INIT; @@ -17973,7 +17977,7 @@ yy1269: TIMELIB_DEINIT; return TIMELIB_GNU_NOCOLON; } -#line 15394 "" +#line 15398 "" yy1270: YYDEBUG(1270, *YYCURSOR); yych = *++YYCURSOR; @@ -18070,7 +18074,7 @@ yy1276: yy1277: YYDEBUG(1277, *YYCURSOR); -#line 970 "resource/parse_date.re" +#line 972 "resource/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("iso8601nocolon"); @@ -18087,7 +18091,7 @@ yy1277: TIMELIB_DEINIT; return TIMELIB_ISO_NOCOLON; } -#line 15492 "" +#line 15496 "" yy1278: YYDEBUG(1278, *YYCURSOR); yyaccept = 21; @@ -18384,7 +18388,7 @@ yy1301: yy1302: YYDEBUG(1302, *YYCURSOR); -#line 860 "resource/parse_date.re" +#line 862 "resource/parse_date.re" { timelib_ull i; @@ -18407,7 +18411,7 @@ yy1302: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 15756 "" +#line 15760 "" yy1303: YYDEBUG(1303, *YYCURSOR); yych = *++YYCURSOR; @@ -18478,7 +18482,7 @@ yy1310: yy1311: YYDEBUG(1311, *YYCURSOR); -#line 848 "resource/parse_date.re" +#line 850 "resource/parse_date.re" { DEBUG_OUTPUT("tomorrow"); TIMELIB_INIT; @@ -18489,7 +18493,7 @@ yy1311: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 15820 "" +#line 15824 "" yy1312: YYDEBUG(1312, *YYCURSOR); yych = *++YYCURSOR; @@ -18502,7 +18506,7 @@ yy1313: yy1314: YYDEBUG(1314, *YYCURSOR); -#line 838 "resource/parse_date.re" +#line 840 "resource/parse_date.re" { DEBUG_OUTPUT("midnight | today"); TIMELIB_INIT; @@ -18511,7 +18515,7 @@ yy1314: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 15836 "" +#line 15840 "" yy1315: YYDEBUG(1315, *YYCURSOR); yych = *++YYCURSOR; @@ -18592,7 +18596,7 @@ yy1322: yy1323: YYDEBUG(1323, *YYCURSOR); -#line 817 "resource/parse_date.re" +#line 819 "resource/parse_date.re" { DEBUG_OUTPUT("now"); TIMELIB_INIT; @@ -18600,7 +18604,7 @@ yy1323: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 15907 "" +#line 15911 "" yy1324: YYDEBUG(1324, *YYCURSOR); yych = *++YYCURSOR; @@ -18620,7 +18624,7 @@ yy1325: yy1326: YYDEBUG(1326, *YYCURSOR); -#line 826 "resource/parse_date.re" +#line 828 "resource/parse_date.re" { DEBUG_OUTPUT("noon"); TIMELIB_INIT; @@ -18631,7 +18635,7 @@ yy1326: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 15932 "" +#line 15936 "" yy1327: YYDEBUG(1327, *YYCURSOR); yych = *++YYCURSOR; @@ -18689,7 +18693,7 @@ yy1334: yy1335: YYDEBUG(1335, *YYCURSOR); -#line 805 "resource/parse_date.re" +#line 807 "resource/parse_date.re" { DEBUG_OUTPUT("yesterday"); TIMELIB_INIT; @@ -18700,10 +18704,10 @@ yy1335: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 15983 "" +#line 15987 "" } } -#line 1367 "resource/parse_date.re" +#line 1371 "resource/parse_date.re" } diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re index 1fdbfec55e..34f9aa5723 100644 --- a/ext/date/lib/parse_date.re +++ b/ext/date/lib/parse_date.re @@ -100,7 +100,7 @@ typedef unsigned char uchar; #define TIMELIB_UNHAVE_TIME() { s->time->have_time = 0; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; } #define TIMELIB_HAVE_DATE() { if (s->time->have_date) { return TIMELIB_ERROR; } else { s->time->have_date = 1; } } #define TIMELIB_UNHAVE_DATE() { s->time->have_date = 0; s->time->d = 0; s->time->m = 0; s->time->y = 0; } -#define TIMELIB_HAVE_RELATIVE() { s->time->have_relative = 1; } +#define TIMELIB_HAVE_RELATIVE() { s->time->have_relative = 1; s->time->relative.weekday_behavior = 0; } #define TIMELIB_HAVE_WEEKDAY_RELATIVE() { s->time->have_weekday_relative = 1; } #define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return TIMELIB_ERROR; } else { s->time.have_zone = 1; } } @@ -222,8 +222,8 @@ static timelib_lookup_table const timelib_reltext_lookup[] = { { "twelfth", 0, 12 }, { "last", 0, -1 }, { "previous", 0, -1 }, - { "this", 0, 0 }, - { NULL, 0, 0 } + { "this", 1, 0 }, + { NULL, 1, 0 } }; /* The month table. */ @@ -439,7 +439,7 @@ static long timelib_parse_tz_cor(char **ptr) return 0; } -static timelib_sll timelib_lookup_relative_text(char **ptr) +static timelib_sll timelib_lookup_relative_text(char **ptr, int *behavior) { char *word; char *begin = *ptr, *end; @@ -456,6 +456,7 @@ static timelib_sll timelib_lookup_relative_text(char **ptr) for (tp = timelib_reltext_lookup; tp->name; tp++) { if (strcasecmp(word, tp->name) == 0) { value = tp->value; + *behavior = tp->type; } } @@ -463,12 +464,12 @@ static timelib_sll timelib_lookup_relative_text(char **ptr) return value; } -static timelib_sll timelib_get_relative_text(char **ptr) +static timelib_sll timelib_get_relative_text(char **ptr, int *behavior) { while (**ptr == ' ' || **ptr == '-' || **ptr == '/') { ++*ptr; } - return timelib_lookup_relative_text(ptr); + return timelib_lookup_relative_text(ptr, behavior); } static long timelib_lookup_month(char **ptr) @@ -534,7 +535,7 @@ static const timelib_relunit* timelib_lookup_relunit(char **ptr) return value; } -static void timelib_set_relative(char **ptr, timelib_sll amount, Scanner *s) +static void timelib_set_relative(char **ptr, timelib_sll amount, int behavior, Scanner *s) { const timelib_relunit* relunit; @@ -552,6 +553,7 @@ static void timelib_set_relative(char **ptr, timelib_sll amount, Scanner *s) TIMELIB_UNHAVE_TIME(); s->time->relative.d += (amount > 0 ? amount - 1 : amount) * 7; s->time->relative.weekday = relunit->multiplier; + s->time->relative.weekday_behavior = behavior; break; } } @@ -1257,14 +1259,15 @@ relativetext = (reltextnumber space? reltextunit)+; relativetext { timelib_sll i; + int behavior; DEBUG_OUTPUT("relativetext"); TIMELIB_INIT; TIMELIB_HAVE_RELATIVE(); while(*ptr) { - i = timelib_get_relative_text((char **) &ptr); + i = timelib_get_relative_text((char **) &ptr, &behavior); timelib_eat_spaces((char **) &ptr); - timelib_set_relative((char **) &ptr, i, s); + timelib_set_relative((char **) &ptr, i, behavior, s); } TIMELIB_DEINIT; return TIMELIB_RELATIVE; @@ -1281,6 +1284,7 @@ relativetext = (reltextnumber space? reltextunit)+; relunit = timelib_lookup_relunit((char**) &ptr); s->time->relative.weekday = relunit->multiplier; + s->time->relative.weekday_behavior = 1; TIMELIB_DEINIT; return TIMELIB_RELATIVE; @@ -1341,7 +1345,7 @@ relativetext = (reltextnumber space? reltextunit)+; while(*ptr) { i = timelib_get_unsigned_nr((char **) &ptr, 24); timelib_eat_spaces((char **) &ptr); - timelib_set_relative((char **) &ptr, i, s); + timelib_set_relative((char **) &ptr, i, 0, s); } TIMELIB_DEINIT; return TIMELIB_RELATIVE; diff --git a/ext/date/lib/resource/parse_date.re b/ext/date/lib/resource/parse_date.re index 1fdbfec55e..34f9aa5723 100644 --- a/ext/date/lib/resource/parse_date.re +++ b/ext/date/lib/resource/parse_date.re @@ -100,7 +100,7 @@ typedef unsigned char uchar; #define TIMELIB_UNHAVE_TIME() { s->time->have_time = 0; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; } #define TIMELIB_HAVE_DATE() { if (s->time->have_date) { return TIMELIB_ERROR; } else { s->time->have_date = 1; } } #define TIMELIB_UNHAVE_DATE() { s->time->have_date = 0; s->time->d = 0; s->time->m = 0; s->time->y = 0; } -#define TIMELIB_HAVE_RELATIVE() { s->time->have_relative = 1; } +#define TIMELIB_HAVE_RELATIVE() { s->time->have_relative = 1; s->time->relative.weekday_behavior = 0; } #define TIMELIB_HAVE_WEEKDAY_RELATIVE() { s->time->have_weekday_relative = 1; } #define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return TIMELIB_ERROR; } else { s->time.have_zone = 1; } } @@ -222,8 +222,8 @@ static timelib_lookup_table const timelib_reltext_lookup[] = { { "twelfth", 0, 12 }, { "last", 0, -1 }, { "previous", 0, -1 }, - { "this", 0, 0 }, - { NULL, 0, 0 } + { "this", 1, 0 }, + { NULL, 1, 0 } }; /* The month table. */ @@ -439,7 +439,7 @@ static long timelib_parse_tz_cor(char **ptr) return 0; } -static timelib_sll timelib_lookup_relative_text(char **ptr) +static timelib_sll timelib_lookup_relative_text(char **ptr, int *behavior) { char *word; char *begin = *ptr, *end; @@ -456,6 +456,7 @@ static timelib_sll timelib_lookup_relative_text(char **ptr) for (tp = timelib_reltext_lookup; tp->name; tp++) { if (strcasecmp(word, tp->name) == 0) { value = tp->value; + *behavior = tp->type; } } @@ -463,12 +464,12 @@ static timelib_sll timelib_lookup_relative_text(char **ptr) return value; } -static timelib_sll timelib_get_relative_text(char **ptr) +static timelib_sll timelib_get_relative_text(char **ptr, int *behavior) { while (**ptr == ' ' || **ptr == '-' || **ptr == '/') { ++*ptr; } - return timelib_lookup_relative_text(ptr); + return timelib_lookup_relative_text(ptr, behavior); } static long timelib_lookup_month(char **ptr) @@ -534,7 +535,7 @@ static const timelib_relunit* timelib_lookup_relunit(char **ptr) return value; } -static void timelib_set_relative(char **ptr, timelib_sll amount, Scanner *s) +static void timelib_set_relative(char **ptr, timelib_sll amount, int behavior, Scanner *s) { const timelib_relunit* relunit; @@ -552,6 +553,7 @@ static void timelib_set_relative(char **ptr, timelib_sll amount, Scanner *s) TIMELIB_UNHAVE_TIME(); s->time->relative.d += (amount > 0 ? amount - 1 : amount) * 7; s->time->relative.weekday = relunit->multiplier; + s->time->relative.weekday_behavior = behavior; break; } } @@ -1257,14 +1259,15 @@ relativetext = (reltextnumber space? reltextunit)+; relativetext { timelib_sll i; + int behavior; DEBUG_OUTPUT("relativetext"); TIMELIB_INIT; TIMELIB_HAVE_RELATIVE(); while(*ptr) { - i = timelib_get_relative_text((char **) &ptr); + i = timelib_get_relative_text((char **) &ptr, &behavior); timelib_eat_spaces((char **) &ptr); - timelib_set_relative((char **) &ptr, i, s); + timelib_set_relative((char **) &ptr, i, behavior, s); } TIMELIB_DEINIT; return TIMELIB_RELATIVE; @@ -1281,6 +1284,7 @@ relativetext = (reltextnumber space? reltextunit)+; relunit = timelib_lookup_relunit((char**) &ptr); s->time->relative.weekday = relunit->multiplier; + s->time->relative.weekday_behavior = 1; TIMELIB_DEINIT; return TIMELIB_RELATIVE; @@ -1341,7 +1345,7 @@ relativetext = (reltextnumber space? reltextunit)+; while(*ptr) { i = timelib_get_unsigned_nr((char **) &ptr, 24); timelib_eat_spaces((char **) &ptr); - timelib_set_relative((char **) &ptr, i, s); + timelib_set_relative((char **) &ptr, i, 0, s); } TIMELIB_DEINIT; return TIMELIB_RELATIVE; diff --git a/ext/date/lib/timelib.c b/ext/date/lib/timelib.c index 94cc8a0255..18bcf9fc11 100644 --- a/ext/date/lib/timelib.c +++ b/ext/date/lib/timelib.c @@ -180,7 +180,7 @@ void timelib_dump_date(timelib_time *d, int options) d->relative.y, d->relative.m, d->relative.d, d->relative.h, d->relative.i, d->relative.s); } if (d->have_weekday_relative) { - printf(" / %d", d->relative.weekday); + printf(" / %d.%d", d->relative.weekday, d->relative.weekday_behavior); } } printf("\n"); diff --git a/ext/date/lib/timelib_structs.h b/ext/date/lib/timelib_structs.h index 7a46c6573c..317709336c 100644 --- a/ext/date/lib/timelib_structs.h +++ b/ext/date/lib/timelib_structs.h @@ -114,6 +114,7 @@ typedef struct timelib_rel_time { timelib_sll h, i, s; /* Hours, mInutes and Seconds */ int weekday; /* Stores the day in 'next monday' */ + int weekday_behavior; /* 0: the current day should *not* be counted when advancing forwards; 1: the current day *should* be counted */ } timelib_rel_time; typedef struct timelib_time_offset { diff --git a/ext/date/lib/tm2unixtime.c b/ext/date/lib/tm2unixtime.c index 5a555d4b27..dfc32b4d87 100644 --- a/ext/date/lib/tm2unixtime.c +++ b/ext/date/lib/tm2unixtime.c @@ -90,7 +90,7 @@ static void do_adjust_for_weekday(timelib_time* time) current_dow = timelib_day_of_week(time->y, time->m, time->d); difference = time->relative.weekday - current_dow; - if ((time->relative.d < 0 && difference < 0) || (time->relative.d >= 0 && difference <= 0)) { + if ((time->relative.d < 0 && difference < 0) || (time->relative.d >= 0 && difference <= -time->relative.weekday_behavior)) { difference += 7; } if (time->relative.weekday >= 0) { diff --git a/ext/date/tests/bug20382-2.phpt b/ext/date/tests/bug20382-2.phpt index f4a4d12b76..6e6a1ba6fa 100644 --- a/ext/date/tests/bug20382-2.phpt +++ b/ext/date/tests/bug20382-2.phpt @@ -38,7 +38,7 @@ foreach ($tests as $test) { $timestamp = call_user_func_array('mktime', $test); print "ts = ". date("l Y-m-d H:i:s T", $timestamp). "\n"; - $strtotime_tstamp = strtotime("Monday", $timestamp); + $strtotime_tstamp = strtotime("first monday", $timestamp); print "result = ".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted = Monday 00:00:00\n\n"; } diff --git a/ext/date/tests/bug33414-1.phpt b/ext/date/tests/bug33414-1.phpt index cbb6b5f5c9..7b15228cf3 100644 --- a/ext/date/tests/bug33414-1.phpt +++ b/ext/date/tests/bug33414-1.phpt @@ -7,7 +7,7 @@ print "TZ=America/Mendoza - wrong day.\n"; putenv("TZ=America/Mendoza"); $tStamp = mktime (17, 17, 17, 1, 8327, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Sunday", $tStamp); +$strtotime_tstamp = strtotime("next Sunday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Sunday 00:00:00\n\n"; @@ -15,7 +15,7 @@ print "TZ=America/Catamarca - wrong day.\n"; putenv("TZ=America/Catamarca"); $tStamp = mktime (17, 17, 17, 1, 7599, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Sunday", $tStamp); +$strtotime_tstamp = strtotime("next Sunday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Sunday 00:00:00\n\n"; @@ -23,7 +23,7 @@ print "TZ=America/Cordoba - wrong day.\n"; putenv("TZ=America/Cordoba"); $tStamp = mktime (17, 17, 17, 1, 7599, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Sunday", $tStamp); +$strtotime_tstamp = strtotime("next Sunday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Sunday 00:00:00\n\n"; @@ -31,7 +31,7 @@ print "TZ=America/Rosario - wrong day.\n"; putenv("TZ=America/Rosario"); $tStamp = mktime (17, 17, 17, 1, 7958, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Tuesday", $tStamp); +$strtotime_tstamp = strtotime("next Tuesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Tuesday 00:00:00\n\n"; @@ -40,7 +40,7 @@ least on my system :-)\n"; putenv("TZ=Europe/Vienna"); $tStamp = mktime (17, 17, 17, 1, 3746, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Thursday", $tStamp); +$strtotime_tstamp = strtotime("next Thursday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Thursday 00:00:00\n\n"; @@ -48,7 +48,7 @@ print "TZ=Asia/Baku - wrong day.\n"; putenv("TZ=Asia/Baku"); $tStamp = mktime (17, 17, 17, 1, 8299, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Sunday", $tStamp); +$strtotime_tstamp = strtotime("next Sunday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Sunday 00:00:00\n\n"; @@ -56,7 +56,7 @@ print "TZ=America/Noronha - wrong day.\n"; putenv("TZ=America/Noronha"); $tStamp = mktime (17, 17, 17, 1, 10866, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Friday", $tStamp); +$strtotime_tstamp = strtotime("next Friday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Friday 00:00:00\n\n"; @@ -64,7 +64,7 @@ print "TZ=America/Havana - wrong day.\n"; putenv("TZ=America/Havana"); $tStamp = mktime (17, 17, 17, 1, 12720, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Thursday", $tStamp); +$strtotime_tstamp = strtotime("next Thursday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Thursday 00:00:00\n\n"; @@ -72,7 +72,7 @@ print "TZ=Europe/Tallinn - wrong day.\n"; putenv("TZ=Europe/Tallinn"); $tStamp = mktime (17, 17, 17, 1, 11777, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Saturday", $tStamp); +$strtotime_tstamp = strtotime("next Saturday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Saturday 00:00:00\n\n"; @@ -80,7 +80,7 @@ print "TZ=Asia/Jerusalem - wrong day.\n"; putenv("TZ=Asia/Jerusalem"); $tStamp = mktime (17, 17, 17, 1, 13056, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Thursday", $tStamp); +$strtotime_tstamp = strtotime("next Thursday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Thursday 00:00:00\n\n"; @@ -88,7 +88,7 @@ print "TZ=Europe/Vilnius - wrong day.\n"; putenv("TZ=Europe/Vilnius"); $tStamp = mktime (17, 17, 17, 1, 12140, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Friday", $tStamp); +$strtotime_tstamp = strtotime("next Friday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Friday 00:00:00\n\n"; @@ -96,7 +96,7 @@ print "TZ=Pacific/Kwajalein - wrong day.\n"; putenv("TZ=Pacific/Kwajalein"); $tStamp = mktime (17, 17, 17, 1, 8626, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Friday", $tStamp); +$strtotime_tstamp = strtotime("next Friday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Friday 00:00:00\n\n"; @@ -104,7 +104,7 @@ print "TZ=Asia/Ulan_Bator - wrong day.\n"; putenv("TZ=Asia/Ulan_Bator"); $tStamp = mktime (17, 17, 17, 1, 11588, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Saturday", $tStamp); +$strtotime_tstamp = strtotime("next Saturday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Saturday 00:00:00\n\n"; @@ -112,7 +112,7 @@ print "TZ=America/Cancun - wrong day.\n"; putenv("TZ=America/Cancun"); $tStamp = mktime (17, 17, 17, 1, 11785, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Sunday", $tStamp); +$strtotime_tstamp = strtotime("next Sunday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Sunday 00:00:00\n\n"; @@ -120,7 +120,7 @@ print "TZ=America/Mexico_City - wrong day.\n"; putenv("TZ=America/Mexico_City"); $tStamp = mktime (17, 17, 17, 1, 11781, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Wednesday", $tStamp); +$strtotime_tstamp = strtotime("next Wednesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Wednesday 00:00:00\n\n"; @@ -128,7 +128,7 @@ print "TZ=America/Mazatlan - wrong day.\n"; putenv("TZ=America/Mazatlan"); $tStamp = mktime (17, 17, 17, 1, 11780, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Tuesday", $tStamp); +$strtotime_tstamp = strtotime("next Tuesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Tuesday 00:00:00\n\n"; @@ -136,7 +136,7 @@ print "TZ=America/Chihuahua - wrong day.\n"; putenv("TZ=America/Chihuahua"); $tStamp = mktime (17, 17, 17, 1, 11782, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Thursday", $tStamp); +$strtotime_tstamp = strtotime("next Thursday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Thursday 00:00:00\n\n"; @@ -144,7 +144,7 @@ print "TZ=Asia/Kuala_Lumpur - wrong day.\n"; putenv("TZ=Asia/Kuala_Lumpur"); $tStamp = mktime (17, 17, 17, 1, 4380, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Monday", $tStamp); +$strtotime_tstamp = strtotime("next Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; @@ -152,7 +152,7 @@ print "TZ=Pacific/Chatham - wrong day.\n"; putenv("TZ=Pacific/Chatham"); $tStamp = mktime (17, 17, 17, 1, 1762, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Monday", $tStamp); +$strtotime_tstamp = strtotime("next Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; @@ -160,7 +160,7 @@ print "TZ=America/Lima - wrong day.\n"; putenv("TZ=America/Lima"); $tStamp = mktime (17, 17, 17, 1, 5839, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Thursday", $tStamp); +$strtotime_tstamp = strtotime("next Thursday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Thursday 00:00:00\n\n"; @@ -168,7 +168,7 @@ print "TZ=Asia/Karachi - wrong day.\n"; putenv("TZ=Asia/Karachi"); $tStamp = mktime (17, 17, 17, 1, 11783, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Friday", $tStamp); +$strtotime_tstamp = strtotime("next Friday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Friday 00:00:00\n\n"; @@ -176,7 +176,7 @@ print "TZ=America/Asuncion - wrong day.\n"; putenv("TZ=America/Asuncion"); $tStamp = mktime (17, 17, 17, 1, 11746, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Wednesday", $tStamp); +$strtotime_tstamp = strtotime("next Wednesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Wednesday 00:00:00\n\n"; @@ -184,7 +184,7 @@ print "TZ=Asia/Singapore - wrong day.\n"; putenv("TZ=Asia/Singapore"); $tStamp = mktime (17, 17, 17, 1, 4383, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Thursday", $tStamp); +$strtotime_tstamp = strtotime("next Thursday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Thursday 00:00:00\n\n"; @@ -192,7 +192,7 @@ print "TZ=America/Montevideo - wrong day.\n"; putenv("TZ=America/Montevideo"); $tStamp = mktime (17, 17, 17, 1, 12678, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Thursday", $tStamp); +$strtotime_tstamp = strtotime("next Thursday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Thursday 00:00:00\n\n"; diff --git a/ext/date/tests/bug33414-2.phpt b/ext/date/tests/bug33414-2.phpt index d037e6dc35..8eb2a35697 100644 --- a/ext/date/tests/bug33414-2.phpt +++ b/ext/date/tests/bug33414-2.phpt @@ -6,7 +6,7 @@ print "TZ=Pacific/Rarotonga - wrong day.\n"; putenv("TZ=Pacific/Rarotonga"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Tuesday", $tStamp); +$strtotime_tstamp = strtotime("next Tuesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Tuesday 00:00:00\n\n"; @@ -14,7 +14,7 @@ print "TZ=Atlantic/South_Georgia - wrong day.\n"; putenv("TZ=Atlantic/South_Georgia"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Tuesday", $tStamp); +$strtotime_tstamp = strtotime("next Tuesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Tuesday 00:00:00\n\n"; @@ -22,7 +22,7 @@ print "TZ=America/Port-au-Prince - wrong day.\n"; putenv("TZ=America/Port-au-Prince"); $tStamp = mktime (17, 17, 17, 1, 12871, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Monday", $tStamp); +$strtotime_tstamp = strtotime("next Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; @@ -30,7 +30,7 @@ print "TZ=Pacific/Enderbury - wrong day, off by 2 days.\n"; putenv("TZ=Pacific/Enderbury"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Monday", $tStamp); +$strtotime_tstamp = strtotime("next Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; @@ -38,7 +38,7 @@ print "TZ=Pacific/Kiritimati - wrong day, off by 2 days.\n"; putenv("TZ=Pacific/Kiritimati"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Monday", $tStamp); +$strtotime_tstamp = strtotime("next Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; @@ -46,7 +46,7 @@ print "TZ=America/Managua - wrong day.\n"; putenv("TZ=America/Managua"); $tStamp = mktime (17, 17, 17, 1, 12879, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Tuesday", $tStamp); +$strtotime_tstamp = strtotime("next Tuesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Tuesday 00:00:00\n\n"; @@ -54,7 +54,7 @@ print "TZ=Pacific/Pitcairn - wrong day.\n"; putenv("TZ=Pacific/Pitcairn"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Wednesday", $tStamp); +$strtotime_tstamp = strtotime("next Wednesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Wednesday 00:00:00\n\n"; @@ -62,7 +62,7 @@ print "TZ=Pacific/Fakaofo - wrong day.\n"; putenv("TZ=Pacific/Fakaofo"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Saturday", $tStamp); +$strtotime_tstamp = strtotime("next Saturday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Saturday 00:00:00\n\n"; @@ -70,7 +70,7 @@ print "TZ=Pacific/Johnston - wrong day.\n"; putenv("TZ=Pacific/Johnston"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Friday", $tStamp); +$strtotime_tstamp = strtotime("next Friday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Friday 00:00:00\n\n"; ?> diff --git a/ext/date/tests/bug33415-1.phpt b/ext/date/tests/bug33415-1.phpt index 9642811040..3d36af8a53 100644 --- a/ext/date/tests/bug33415-1.phpt +++ b/ext/date/tests/bug33415-1.phpt @@ -8,7 +8,7 @@ AM as per most DST transitions?\n"; putenv("TZ=America/Jujuy"); $tStamp = mktime (17, 17, 17, 1, 7593, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Monday", $tStamp); +$strtotime_tstamp = strtotime("next Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; @@ -16,7 +16,7 @@ print "TZ=Asia/Tbilisi - Is it OK for this to be 2 AM?\n"; putenv("TZ=Asia/Tbilisi"); $tStamp = mktime (17, 17, 17, 1, 12863, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Sunday", $tStamp); +$strtotime_tstamp = strtotime("next Sunday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Sunday 00:00:00\n\n"; ?> diff --git a/ext/date/tests/bug33415-2.phpt b/ext/date/tests/bug33415-2.phpt index 2e3ccf0f3a..a1e5930b5f 100644 --- a/ext/date/tests/bug33415-2.phpt +++ b/ext/date/tests/bug33415-2.phpt @@ -8,7 +8,7 @@ have a DST or timezone transition.\n"; putenv("TZ=Africa/Bujumbura"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Wednesday", $tStamp); +$strtotime_tstamp = strtotime("next Wednesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Wednesday 00:00:00\n\n"; @@ -16,7 +16,7 @@ print "TZ=Asia/Thimbu - Is it OK for this to be 0:30 AM? yes\n"; putenv("TZ=Asia/Thimbu"); $tStamp = mktime (17, 17, 17, 1, 6476, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Thursday", $tStamp); +$strtotime_tstamp = strtotime("next Thursday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Thursday 00:30:00\n\n"; @@ -25,7 +25,7 @@ appear to have a DST or timezone transition.\n"; putenv("TZ=Indian/Cocos"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Thursday", $tStamp); +$strtotime_tstamp = strtotime("next Thursday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Thursday 00:00:00\n\n"; @@ -34,7 +34,7 @@ not appear to have a DST or timezone transition.\n"; putenv("TZ=Africa/Lubumbashi"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Saturday", $tStamp); +$strtotime_tstamp = strtotime("next Saturday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Saturday 00:00:00\n\n"; @@ -42,7 +42,7 @@ print "TZ=Asia/Kashgar - Is it OK for this to be 3 AM? yes\n"; putenv("TZ=Asia/Kashgar"); $tStamp = mktime (17, 17, 17, 1, 3767, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Thursday", $tStamp); +$strtotime_tstamp = strtotime("next Thursday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Thursday 03:00:00\n\n"; @@ -51,7 +51,7 @@ not appear to have a DST or timezone transition.\n"; putenv("TZ=Indian/Christmas"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Sunday", $tStamp); +$strtotime_tstamp = strtotime("next Sunday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Sunday 00:00:00\n\n"; @@ -59,7 +59,7 @@ print "TZ=America/Santo_Domingo - Is it OK for this to be 0:30 AM? yes\n"; putenv("TZ=America/Santo_Domingo"); $tStamp = mktime (17, 17, 17, 1, 291, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Sunday", $tStamp); +$strtotime_tstamp = strtotime("next Sunday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Sunday 00:30:00\n\n"; @@ -68,7 +68,7 @@ appear to have a DST or timezone transition.\n"; putenv("TZ=Pacific/Truk"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Tuesday", $tStamp); +$strtotime_tstamp = strtotime("next Tuesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Tuesday 00:00:00\n\n"; @@ -77,7 +77,7 @@ not appear to have a DST or timezone transition.\n"; putenv("TZ=Pacific/Ponape"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Monday", $tStamp); +$strtotime_tstamp = strtotime("next Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; @@ -85,7 +85,7 @@ print "TZ=America/Scoresbysund - Is it OK for this to be 2 AM? yes\n"; putenv("TZ=America/Scoresbysund"); $tStamp = mktime (17, 17, 17, 1, 4099, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Sunday", $tStamp); +$strtotime_tstamp = strtotime("next Sunday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Sunday 02:00:00\n\n"; @@ -93,7 +93,7 @@ print "TZ=America/Guyana - Is it OK for this to be 0:45 AM? yes\n"; putenv("TZ=America/Guyana"); $tStamp = mktime (17, 17, 17, 1, 2031, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Thursday", $tStamp); +$strtotime_tstamp = strtotime("next Thursday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Thursday 00:45:00\n\n"; @@ -101,7 +101,7 @@ print "TZ=Asia/Tehran - Is it OK for this to be 0:30 AM? yes\n"; putenv("TZ=Asia/Tehran"); $tStamp = mktime (17, 17, 17, 1, 2855, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Tuesday", $tStamp); +$strtotime_tstamp = strtotime("next Tuesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Tuesday 00:30:00\n\n"; @@ -110,7 +110,7 @@ not appear to have a DST or timezone transition.\n"; putenv("TZ=Pacific/Tarawa"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Monday", $tStamp); +$strtotime_tstamp = strtotime("next Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; @@ -118,7 +118,7 @@ print "TZ=Africa/Monrovia - Is it OK for this to be 00:44:30 AM? yes\n"; putenv("TZ=Africa/Monrovia"); $tStamp = mktime (17, 17, 17, 1, 845, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Monday", $tStamp); +$strtotime_tstamp = strtotime("next Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Monday 00:44:30\n\n"; @@ -126,7 +126,7 @@ print "TZ=Asia/Katmandu - Is it OK for this to 0:15 AM?. yes\n"; putenv("TZ=Asia/Katmandu"); $tStamp = mktime (17, 17, 17, 1, 5838, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Wednesday", $tStamp); +$strtotime_tstamp = strtotime("next Wednesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Wednesday 00:15:00\n\n"; @@ -134,7 +134,7 @@ print "TZ=Pacific/Nauru - Is it OK for this to be 0:30? yes\n"; putenv("TZ=Pacific/Nauru"); $tStamp = mktime (17, 17, 17, 1, 3401, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Tuesday", $tStamp); +$strtotime_tstamp = strtotime("next Tuesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Tuesday 00:30:00\n\n"; @@ -142,7 +142,7 @@ print "TZ=Pacific/Niue - Is it OK for this to be 0:30 AM? yes\n"; putenv("TZ=Pacific/Niue"); $tStamp = mktime (17, 17, 17, 1, 3189, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Sunday", $tStamp); +$strtotime_tstamp = strtotime("next Sunday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Sunday 00:30:00\n\n"; @@ -151,7 +151,7 @@ or timezone transition.\n"; putenv("TZ=Pacific/Port_Moresby"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Thursday", $tStamp); +$strtotime_tstamp = strtotime("next Thursday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Thursday 00:00:00\n\n"; @@ -159,7 +159,7 @@ print "TZ=America/Miquelon - Is it OK for this to be 1 AM ? yes\n"; putenv("TZ=America/Miquelon"); $tStamp = mktime (17, 17, 17, 1, 3767, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Thursday", $tStamp); +$strtotime_tstamp = strtotime("next Thursday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Thursday 01:00:00\n\n"; @@ -168,7 +168,7 @@ timezone transition.\n"; putenv("TZ=Pacific/Palau"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Saturday", $tStamp); +$strtotime_tstamp = strtotime("next Saturday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Saturday 00:00:00\n\n"; @@ -177,7 +177,7 @@ not appear to have a DST or timezone transition.\n"; putenv("TZ=Pacific/Funafuti"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Wednesday", $tStamp); +$strtotime_tstamp = strtotime("next Wednesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Wednesday 00:00:00\n\n"; @@ -186,7 +186,7 @@ appear to have a DST or timezone transition.\n"; putenv("TZ=Pacific/Wake"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Tuesday", $tStamp); +$strtotime_tstamp = strtotime("next Tuesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Tuesday 00:00:00\n\n"; @@ -195,7 +195,7 @@ not appear to have a DST or timezone transition.\n"; putenv("TZ=Pacific/Wallis"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n"; -$strtotime_tstamp = strtotime("Tuesday", $tStamp); +$strtotime_tstamp = strtotime("next Tuesday", $tStamp); print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n"; print "wanted=Tuesday 00:00:00\n\n"; -- 2.40.0