diff options
author | Derick Rethans <github@derickrethans.nl> | 2015-03-31 16:36:51 +0100 |
---|---|---|
committer | Derick Rethans <github@derickrethans.nl> | 2015-03-31 16:36:51 +0100 |
commit | d252c9f8324a1fac35aac01b7de7cc800ea76865 (patch) | |
tree | bbe072e421fd408029f6c74e3bbd5c53b9862172 | |
parent | 1737e44dec534d8bbbe5f8e5beefe6edc780ff10 (diff) | |
parent | 2d3868984cc0c43dd66f5aa0d2e56a92821300a6 (diff) | |
download | php-git-d252c9f8324a1fac35aac01b7de7cc800ea76865.tar.gz |
Merge branch 'PHP-5.6'
Conflicts:
ext/date/lib/parse_date.c
ext/date/php_date.c
-rw-r--r-- | ext/date/lib/parse_date.c | 6 | ||||
-rw-r--r-- | ext/date/lib/parse_date.re | 4 | ||||
-rw-r--r-- | ext/date/lib/timelib.h | 3 | ||||
-rw-r--r-- | ext/date/lib/tm2unixtime.c | 15 | ||||
-rw-r--r-- | ext/date/php_date.c | 2 | ||||
-rw-r--r-- | ext/date/tests/bug69336.phpt | 20 |
6 files changed, 42 insertions, 8 deletions
diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c index 9e0ca6edf3..84414e9aef 100644 --- a/ext/date/lib/parse_date.c +++ b/ext/date/lib/parse_date.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Thu Oct 30 18:16:16 2014 */ +/* Generated by re2c 0.13.5 on Tue Mar 31 16:32:03 2015 */ #line 1 "ext/date/lib/parse_date.re" /* +----------------------------------------------------------------------+ @@ -19864,9 +19864,9 @@ yy1315: /* skip "last day of" or "first day of" */ if (*ptr == 'l' || *ptr == 'L') { - s->time->relative.first_last_day_of = 2; + s->time->relative.first_last_day_of = TIMELIB_SPECIAL_LAST_DAY_OF_MONTH; } else { - s->time->relative.first_last_day_of = 1; + s->time->relative.first_last_day_of = TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH; } TIMELIB_DEINIT; diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re index 0ac99a591e..9303eae01e 100644 --- a/ext/date/lib/parse_date.re +++ b/ext/date/lib/parse_date.re @@ -1030,9 +1030,9 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of /* skip "last day of" or "first day of" */ if (*ptr == 'l' || *ptr == 'L') { - s->time->relative.first_last_day_of = 2; + s->time->relative.first_last_day_of = TIMELIB_SPECIAL_LAST_DAY_OF_MONTH; } else { - s->time->relative.first_last_day_of = 1; + s->time->relative.first_last_day_of = TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH; } TIMELIB_DEINIT; diff --git a/ext/date/lib/timelib.h b/ext/date/lib/timelib.h index 51f3fbcfc4..a367ef36da 100644 --- a/ext/date/lib/timelib.h +++ b/ext/date/lib/timelib.h @@ -38,6 +38,9 @@ #define TIMELIB_SPECIAL_DAY_OF_WEEK_IN_MONTH 0x02 #define TIMELIB_SPECIAL_LAST_DAY_OF_WEEK_IN_MONTH 0x03 +#define TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH 0x01 +#define TIMELIB_SPECIAL_LAST_DAY_OF_MONTH 0x02 + #ifndef LONG_MAX #define LONG_MAX 2147483647L #endif diff --git a/ext/date/lib/tm2unixtime.c b/ext/date/lib/tm2unixtime.c index c058672f1e..2714c9a4da 100644 --- a/ext/date/lib/tm2unixtime.c +++ b/ext/date/lib/tm2unixtime.c @@ -205,15 +205,17 @@ static void do_adjust_relative(timelib_time* time) time->m += time->relative.m; time->y += time->relative.y; } + switch (time->relative.first_last_day_of) { - case 1: /* first */ + case TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH: /* first */ time->d = 1; break; - case 2: /* last */ + case TIMELIB_SPECIAL_LAST_DAY_OF_MONTH: /* last */ time->d = 0; time->m++; break; } + timelib_do_normalize(time); } @@ -296,6 +298,15 @@ static void do_adjust_special_early(timelib_time* time) break; } } + switch (time->relative.first_last_day_of) { + case TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH: /* first */ + time->d = 1; + break; + case TIMELIB_SPECIAL_LAST_DAY_OF_MONTH: /* last */ + time->d = 0; + time->m++; + break; + } timelib_do_normalize(time); } diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 94d3a19bcd..b3f6a27c9d 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -2967,7 +2967,7 @@ void php_date_do_return_parsed_time(INTERNAL_FUNCTION_PARAMETERS, timelib_time * add_assoc_long(&element, "weekdays", parsed_time->relative.special.amount); } if (parsed_time->relative.first_last_day_of) { - add_assoc_bool(&element, parsed_time->relative.first_last_day_of == 1 ? "first_day_of_month" : "last_day_of_month", 1); + add_assoc_bool(&element, parsed_time->relative.first_last_day_of == TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH ? "first_day_of_month" : "last_day_of_month", 1); } add_assoc_zval(return_value, "relative", &element); } diff --git a/ext/date/tests/bug69336.phpt b/ext/date/tests/bug69336.phpt new file mode 100644 index 0000000000..8444aa30a3 --- /dev/null +++ b/ext/date/tests/bug69336.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #69336 (Issues with "last day of <monthname>") +--INI-- +date.timezone=UTC +--FILE-- +<?php +var_dump(date('d.m.Y',strtotime('last day of april'))); +var_dump(date('d.m.Y',strtotime('last tuesday of march 2015'))); +var_dump(date('d.m.Y',strtotime('last wednesday of march 2015'))); +var_dump(date('d.m.Y',strtotime('last wednesday of april 2015'))); +var_dump(date('d.m.Y',strtotime('last wednesday of march 2014'))); +var_dump(date('d.m.Y',strtotime('last wednesday of april 2014'))); +?> +--EXPECTF-- +string(10) "30.04.%d" +string(10) "31.03.2015" +string(10) "25.03.2015" +string(10) "29.04.2015" +string(10) "26.03.2014" +string(10) "30.04.2014" |