From d36afdf0ee9d7dd116c5897d976d7987ac16fc6a Mon Sep 17 00:00:00 2001 From: xuzhi <767994038@qq.com> Date: Tue, 30 Oct 2012 18:25:20 +0800 Subject: [PATCH 1/5] Update ext/date/lib/tm2unixtime.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix  Bug #63392  由于 我是第一次参与php源码的工作,有很多东西不太清楚。这个bug  不知道原始的作者 是怎么考虑的,会出现那么奇怪的赋值。 --- ext/date/lib/tm2unixtime.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ext/date/lib/tm2unixtime.c b/ext/date/lib/tm2unixtime.c index 37b4f43322e3f..fa87a2ebfc243 100644 --- a/ext/date/lib/tm2unixtime.c +++ b/ext/date/lib/tm2unixtime.c @@ -150,7 +150,14 @@ static void do_adjust_for_weekday(timelib_time* time) if (time->relative.weekday_behavior == 2) { if (time->relative.weekday == 0) { - time->relative.weekday = 7; + /* + 这里不知道为什么 原始的代码是查看这个值等于0的情况,再把这个值赋值为7 。这个导致了 + Bug #63392 ,5.13号 如果 加0的话 就不会产生bug,就是因为这个奇怪的赋值,导致了这个bug,不知道 + 原始的作者是怎么考虑的。 + + + */ + //time->relative.weekday = 7; } time->d -= current_dow; time->d += time->relative.weekday; From a41cbc591914ebc70deba5161cbc58ea0a7ca585 Mon Sep 17 00:00:00 2001 From: xuzhi <767994038@qq.com> Date: Wed, 31 Oct 2012 11:10:25 +0800 Subject: [PATCH 2/5] Update ext/date/lib/tm2unixtime.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix bug #63392 old code is if(time->relative.weekday == 0)time->relative.weekday == 7 i don't konw  why author write this code --- ext/date/lib/tm2unixtime.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ext/date/lib/tm2unixtime.c b/ext/date/lib/tm2unixtime.c index fa87a2ebfc243..d87131dc6086a 100644 --- a/ext/date/lib/tm2unixtime.c +++ b/ext/date/lib/tm2unixtime.c @@ -149,16 +149,6 @@ static void do_adjust_for_weekday(timelib_time* time) current_dow = timelib_day_of_week(time->y, time->m, time->d); if (time->relative.weekday_behavior == 2) { - if (time->relative.weekday == 0) { - /* - 这里不知道为什么 原始的代码是查看这个值等于0的情况,再把这个值赋值为7 。这个导致了 - Bug #63392 ,5.13号 如果 加0的话 就不会产生bug,就是因为这个奇怪的赋值,导致了这个bug,不知道 - 原始的作者是怎么考虑的。 - - - */ - //time->relative.weekday = 7; - } time->d -= current_dow; time->d += time->relative.weekday; return; From 9946033bbad532f279de68fcb19b3473d5ea1cfc Mon Sep 17 00:00:00 2001 From: xuzhi <767994038@qq.com> Date: Thu, 1 Nov 2012 19:34:28 +0800 Subject: [PATCH 3/5] fix bug 63392 --- ext/date/tests/bug63392.phpt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 ext/date/tests/bug63392.phpt diff --git a/ext/date/tests/bug63392.phpt b/ext/date/tests/bug63392.phpt new file mode 100644 index 0000000000000..7e7fd98a036ec --- /dev/null +++ b/ext/date/tests/bug63392.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #63392 (DateTime::modify() start of week inconsistency) +Description: +------------ +Calling $dt->modify("Monday this week") for all dates 13C19 May 2012 (SunCSat) +result in the same date (2012-05-14), suggesting that "this week" runs SunCSat. +However, calling $dt->modify("Sunday this week") gives the "next" Sunday (2012- +05-20) for the same range. + +On a related note, the documentation on relative date formats is lacking on the +behaviour of this and strtotime when used with locales; one might expect the +start of the week to be interpreted from LC_TIME. +--FILE-- +modify("Sunday this week"); +var_dump($dt->format('r') +?> +--EXPECT-- +string(31) "Sun, 13 May 2012 00:00:00 +0000" From a1ec906a2cad6483db73f41adabaffddb7a216e6 Mon Sep 17 00:00:00 2001 From: xuzhi <767994038@qq.com> Date: Fri, 2 Nov 2012 02:17:48 +0800 Subject: [PATCH 4/5] corrent some paste error --- ext/date/tests/bug63392.phpt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/ext/date/tests/bug63392.phpt b/ext/date/tests/bug63392.phpt index 7e7fd98a036ec..c923b269597db 100644 --- a/ext/date/tests/bug63392.phpt +++ b/ext/date/tests/bug63392.phpt @@ -2,20 +2,13 @@ Bug #63392 (DateTime::modify() start of week inconsistency) Description: ------------ -Calling $dt->modify("Monday this week") for all dates 13C19 May 2012 (SunCSat) -result in the same date (2012-05-14), suggesting that "this week" runs SunCSat. -However, calling $dt->modify("Sunday this week") gives the "next" Sunday (2012- -05-20) for the same range. -On a related note, the documentation on relative date formats is lacking on the -behaviour of this and strtotime when used with locales; one might expect the -start of the week to be interpreted from LC_TIME. --FILE-- modify("Sunday this week"); -var_dump($dt->format('r') +var_dump($dt->format('r')); ?> --EXPECT-- string(31) "Sun, 13 May 2012 00:00:00 +0000" From 86fc56c34667a97749fe828f683ffd85aaf14d1c Mon Sep 17 00:00:00 2001 From: xuzhi <767994038@qq.com> Date: Fri, 2 Nov 2012 02:36:16 +0800 Subject: [PATCH 5/5] corrent tomezone setting --- ext/date/tests/bug63392.phpt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ext/date/tests/bug63392.phpt b/ext/date/tests/bug63392.phpt index c923b269597db..51cb7b9ff6d90 100644 --- a/ext/date/tests/bug63392.phpt +++ b/ext/date/tests/bug63392.phpt @@ -3,6 +3,9 @@ Bug #63392 (DateTime::modify() start of week inconsistency) Description: ------------ + +--INI-- +date.timezone=UTC --FILE--