From: Derick Rethans Date: Thu, 17 Jan 2008 20:58:26 +0000 (+0000) Subject: - Fixed bug #41599 (setTime() fails after modify() is used). X-Git-Tag: RELEASE_2_0_0a1~856 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd9bc73574d1fe249ef83a94420993db3adb185a;p=php - Fixed bug #41599 (setTime() fails after modify() is used). --- diff --git a/ext/date/lib/tm2unixtime.c b/ext/date/lib/tm2unixtime.c index 3a7fd24478..4bd1f8f576 100644 --- a/ext/date/lib/tm2unixtime.c +++ b/ext/date/lib/tm2unixtime.c @@ -98,6 +98,7 @@ static void do_adjust_for_weekday(timelib_time* time) } else { time->d -= (7 - (abs(time->relative.weekday) - current_dow)); } + time->have_weekday_relative = 0; } static void do_normalize(timelib_time* time) @@ -130,6 +131,7 @@ static void do_adjust_relative(timelib_time* time) do_normalize(time); memset(&(time->relative), 0, sizeof(time->relative)); + time->have_relative = 0; } static void do_adjust_special_weekday(timelib_time* time) diff --git a/ext/date/tests/bug41599.phpt b/ext/date/tests/bug41599.phpt new file mode 100644 index 0000000000..e4febe2cd8 --- /dev/null +++ b/ext/date/tests/bug41599.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #41599 (setTime() fails after modify() is used) +--FILE-- +format('Y-m-d H:i:s'),PHP_EOL; +//good + +$start->modify('Tuesday'); +echo $start->format('Y-m-d H:i:s'),PHP_EOL; +//good + +$start->setTime(4, 0, 0); +echo $start->format('Y-m-d H:i:s'),PHP_EOL; +//jumped to next Sunday + +$start->setTime(8, 0, 0); +echo $start->format('Y-m-d H:i:s'),PHP_EOL; +//jumped to next Sunday again +?> +--EXPECT-- +2008-01-14 00:00:00 +2008-01-15 00:00:00 +2008-01-15 04:00:00 +2008-01-15 08:00:00