]> granicus.if.org Git - php/commitdiff
- Fixed bug #41599 (setTime() fails after modify() is used).
authorDerick Rethans <derick@php.net>
Thu, 17 Jan 2008 20:58:26 +0000 (20:58 +0000)
committerDerick Rethans <derick@php.net>
Thu, 17 Jan 2008 20:58:26 +0000 (20:58 +0000)
ext/date/lib/tm2unixtime.c
ext/date/tests/bug41599.phpt [new file with mode: 0644]

index 3a7fd2447876692ec88e77f03448b8a8065ed34b..4bd1f8f576cfcef183c8ceed5ececaed4006a6ae 100644 (file)
@@ -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 (file)
index 0000000..e4febe2
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Bug #41599 (setTime() fails after modify() is used)
+--FILE--
+<?php
+date_default_timezone_set('Europe/London');
+
+$start = new DateTime('2008-01-17 last Monday');
+echo $start->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