Skip to content

Commit 2d38689

Browse files
committed
Merge branch 'PHP-5.5' into PHP-5.6
2 parents 133c571 + ffbd380 commit 2d38689

File tree

6 files changed

+42
-8
lines changed

6 files changed

+42
-8
lines changed

ext/date/lib/parse_date.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Generated by re2c 0.13.5 on Mon Aug 18 18:28:27 2014 */
1+
/* Generated by re2c 0.13.5 on Tue Mar 31 16:32:03 2015 */
22
#line 1 "ext/date/lib/parse_date.re"
33
/*
44
+----------------------------------------------------------------------+
@@ -19864,9 +19864,9 @@ static int scan(Scanner *s, timelib_tz_get_wrapper tz_get_wrapper)
1986419864

1986519865
/* skip "last day of" or "first day of" */
1986619866
if (*ptr == 'l' || *ptr == 'L') {
19867-
s->time->relative.first_last_day_of = 2;
19867+
s->time->relative.first_last_day_of = TIMELIB_SPECIAL_LAST_DAY_OF_MONTH;
1986819868
} else {
19869-
s->time->relative.first_last_day_of = 1;
19869+
s->time->relative.first_last_day_of = TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH;
1987019870
}
1987119871

1987219872
TIMELIB_DEINIT;

ext/date/lib/parse_date.re

+2-2
Original file line numberDiff line numberDiff line change
@@ -1030,9 +1030,9 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
10301030

10311031
/* skip "last day of" or "first day of" */
10321032
if (*ptr == 'l' || *ptr == 'L') {
1033-
s->time->relative.first_last_day_of = 2;
1033+
s->time->relative.first_last_day_of = TIMELIB_SPECIAL_LAST_DAY_OF_MONTH;
10341034
} else {
1035-
s->time->relative.first_last_day_of = 1;
1035+
s->time->relative.first_last_day_of = TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH;
10361036
}
10371037

10381038
TIMELIB_DEINIT;

ext/date/lib/timelib.h

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
#define TIMELIB_SPECIAL_DAY_OF_WEEK_IN_MONTH 0x02
3939
#define TIMELIB_SPECIAL_LAST_DAY_OF_WEEK_IN_MONTH 0x03
4040

41+
#define TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH 0x01
42+
#define TIMELIB_SPECIAL_LAST_DAY_OF_MONTH 0x02
43+
4144
#ifndef LONG_MAX
4245
#define LONG_MAX 2147483647L
4346
#endif

ext/date/lib/tm2unixtime.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,17 @@ static void do_adjust_relative(timelib_time* time)
205205
time->m += time->relative.m;
206206
time->y += time->relative.y;
207207
}
208+
208209
switch (time->relative.first_last_day_of) {
209-
case 1: /* first */
210+
case TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH: /* first */
210211
time->d = 1;
211212
break;
212-
case 2: /* last */
213+
case TIMELIB_SPECIAL_LAST_DAY_OF_MONTH: /* last */
213214
time->d = 0;
214215
time->m++;
215216
break;
216217
}
218+
217219
timelib_do_normalize(time);
218220
}
219221

@@ -296,6 +298,15 @@ static void do_adjust_special_early(timelib_time* time)
296298
break;
297299
}
298300
}
301+
switch (time->relative.first_last_day_of) {
302+
case TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH: /* first */
303+
time->d = 1;
304+
break;
305+
case TIMELIB_SPECIAL_LAST_DAY_OF_MONTH: /* last */
306+
time->d = 0;
307+
time->m++;
308+
break;
309+
}
299310
timelib_do_normalize(time);
300311
}
301312

ext/date/php_date.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3050,7 +3050,7 @@ void php_date_do_return_parsed_time(INTERNAL_FUNCTION_PARAMETERS, timelib_time *
30503050
add_assoc_long(element, "weekdays", parsed_time->relative.special.amount);
30513051
}
30523052
if (parsed_time->relative.first_last_day_of) {
3053-
add_assoc_bool(element, parsed_time->relative.first_last_day_of == 1 ? "first_day_of_month" : "last_day_of_month", 1);
3053+
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);
30543054
}
30553055
add_assoc_zval(return_value, "relative", element);
30563056
}

ext/date/tests/bug69336.phpt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #69336 (Issues with "last day of <monthname>")
3+
--INI--
4+
date.timezone=UTC
5+
--FILE--
6+
<?php
7+
var_dump(date('d.m.Y',strtotime('last day of april')));
8+
var_dump(date('d.m.Y',strtotime('last tuesday of march 2015')));
9+
var_dump(date('d.m.Y',strtotime('last wednesday of march 2015')));
10+
var_dump(date('d.m.Y',strtotime('last wednesday of april 2015')));
11+
var_dump(date('d.m.Y',strtotime('last wednesday of march 2014')));
12+
var_dump(date('d.m.Y',strtotime('last wednesday of april 2014')));
13+
?>
14+
--EXPECTF--
15+
string(10) "30.04.%d"
16+
string(10) "31.03.2015"
17+
string(10) "25.03.2015"
18+
string(10) "29.04.2015"
19+
string(10) "26.03.2014"
20+
string(10) "30.04.2014"

0 commit comments

Comments
 (0)