. Fixed bug #61471 (Incomplete POST does not timeout but is passed to PHP).
(Zheng Shao)
+- Date:
+ . Fixed bug #72719 (Relative datetime format ignores weekday on sundays
+ only). (Derick)
+ . Fixed bug #73294 (DateTime wrong when date string is negative). (Derick)
+ . Fixed bug #73489 (wrong timestamp when call setTimeZone multi times with
+ UTC offset). (xiami, Derick)
+ . Fixed bug #73858 (first/last day of' flag is not being reset). (Derick)
+ . Fixed bug #73942 ($date->modify('Friday this week') doesn't return a Friday
+ if $date is a Sunday). (Derick)
+ . Fixed bug #74057 (wrong day when using "this week" in strtotime). (Derick)
+
- FPM:
. Fixed bug #69860 (php-fpm process accounting is broken with keepalive).
(Denis Yeldandi)
{
/* To make "this week" work, where the current DOW is a "sunday" */
if (current_dow == 0 && time->relative.weekday != 0) {
- time->relative.weekday = -6;
+ time->relative.weekday -= 7;
}
/* To make "sunday this week" work, where the current DOW is not a
return res;
}
-static timelib_sll do_months(timelib_ull month, timelib_ull year)
+static timelib_sll do_months(timelib_ull month, timelib_sll year)
{
if (timelib_is_leap(year)) {
return ((month_tab_leap[month - 1] + 1) * SECS_PER_DAY);
time->sse = res;
time->sse_uptodate = 1;
- time->have_relative = time->relative.have_weekday_relative = time->relative.have_special_relative = 0;
+ time->have_relative = time->relative.have_weekday_relative = time->relative.have_special_relative = time->relative.first_last_day_of = 0;
}
#if 0
timelib_unixtime2gmt(tm, ts - (tm->z * 60) + (tm->dst * 3600));
+ tm->sse = ts;
tm->z = z;
tm->dst = dst;
break;
--- /dev/null
+--TEST--
+Bug #72719: Relative datetime format ignores weekday on sundays only
+--FILE--
+<?php
+echo (new DateTimeImmutable('Monday next week 13:00'))->format('l'), "\n";
+echo (new DateTimeImmutable('Tuesday next week 14:00'))->format('l'), "\n";
+echo (new DateTimeImmutable('Wednesday next week 14:00'))->format('l'), "\n";
+echo (new DateTimeImmutable('Thursday next week 15:00'))->format('l'), "\n";
+echo (new DateTimeImmutable('Friday next week 16:00'))->format('l'), "\n";
+echo (new DateTimeImmutable('Saturday next week 17:00'))->format('l'), "\n";
+echo (new DateTimeImmutable('Sunday next week 18:00'))->format('l'), "\n";
+?>
+--EXPECT--
+Monday
+Tuesday
+Wednesday
+Thursday
+Friday
+Saturday
+Sunday
--- /dev/null
+--TEST--
+Bug #73294: DateTime wrong when date string is negative
+--FILE--
+<?php
+for ( $i = -1050; $i <= -1000; $i++ )
+{
+ $M = "06";
+ $D = "22";
+
+ $dt = new DateTime("{$i}-{$M}-{$D} 00:00:00");
+ $expected = "{$i}-{$M}-{$D} 00:00:00";
+ $result = $dt->format('Y-m-d H:i:s');
+
+ if ( $expected != $result )
+ {
+ echo "Wrong: Should have been {$expected}, was {$result}\n";
+ }
+}
+?>
+==DONE==
+--EXPECT--
+==DONE==
--- /dev/null
+--TEST--
+Bug #73489: wrong timestamp when call setTimeZone multi times with UTC offset
+--FILE--
+<?php
+// example 1 - Timestamp is changing
+$datetime = new DateTime('2016-11-09 20:00:00', new DateTimeZone('UTC'));
+var_dump($datetime->getTimestamp());
+$datetime->setTimeZone(new DateTimeZone('-03:00'));
+$datetime->setTimeZone(new DateTimeZone('-03:00'));
+var_dump($datetime->getTimestamp());
+
+// example 2 - Timestamp keeps if you use getTimestamp() before second setTimeZone() calls
+$datetime = new DateTime('2016-11-09 20:00:00', new DateTimeZone('UTC'));
+var_dump($datetime->getTimestamp());
+$datetime->setTimeZone(new DateTimeZone('-03:00'));
+$datetime->getTimestamp();
+$datetime->setTimeZone(new DateTimeZone('-03:00'));
+var_dump($datetime->getTimestamp());
+?>
+--EXPECT--
+int(1478721600)
+int(1478721600)
+int(1478721600)
+int(1478721600)
--- /dev/null
+--TEST--
+Bug #73858: diff() of two relative/described DateTimes is wrong
+--FILE--
+<?php
+/*
+In the "verbose setup method" I'm trying setup the DateTime object myself
+to see if it's the format string which is parsed in correctly or if it's the DateTime
+object which is breaking stuff. From the testing it appears DateTime is broken somehow.
+*/
+$ss = 'first day of last month midnight';
+$es = 'first day of this month midnight - 1 second';
+
+$s = new DateTime($ss);
+$e = new DateTime($es);
+$d= $e->diff($s);
+var_dump($d->days); // 0 ... but should be 30
+
+$s = (new DateTime(null))->setTimestamp(strtotime($ss)); // verbose setup method
+$e = (new DateTime(null))->setTimestamp(strtotime($es)); // verbose setup method
+$d = $e->diff($s);
+var_dump($d->days); // 30 ... and should be 30
+
+/*
+Next we will try mix/match the code to see what happens, surprisingly it seems that the end date ($e)
+is the important one, if it uses the verbose method it returns the correct values.
+*/
+$s = (new DateTime(null))->setTimestamp(strtotime($ss)); // verbose setup method
+$e = new DateTime($es);
+$d= $e->diff($s);
+var_dump($d->days); // 0 ... but should be 30
+
+$s = new DateTime($ss);
+$e = (new DateTime(null))->setTimestamp(strtotime($es)); // verbose setup method
+$d= $e->diff($s);
+var_dump($d->days); // 30 ... and should be 30
+
+/*
+This test just proves that the $e date is important BUT NOT because it's the one we call the diff() method
+on, that's just coincidental that seems to imply that the "- 1 second" in the date string is the problem.
+*/
+$s = new DateTime($ss);
+$e = (new DateTime(null))->setTimestamp(strtotime($es)); // verbose setup method
+$d= $s->diff($e);
+var_dump($d->days); // 30 ... and should be 30
+
+/*
+[Workaround]
+This final test seems to prove that the input string is important and that the "- 1 secord" has a negative knock-on
+effect on the results of the diff. By modifying the datetime with ->modify everything works as expected ...
+it just means you have to be careful of how we work with DateTimes .
+*/
+$s = new DateTime($ss);
+$e = new DateTime('first day of this month midnight');
+$e->modify('- 1 second');
+var_dump($e->diff($s)->days); // 30 ... and should be 30
+?>
+--EXPECT--
+int(30)
+int(30)
+int(30)
+int(30)
+int(30)
+int(30)
--- /dev/null
+--TEST--
+Bug #73942: $date->modify('Friday this week') doesn't return a Friday if $date is a Sunday
+--FILE--
+<?php
+$date1 = "2017-01-08"; // this is a Sunday
+$date = new \DateTime($date1);
+$date->modify('Friday this week');
+$dateFormat = $date->format('Y-m-d');
+echo $dateFormat, "\n";
+?>
+--EXPECT--
+2017-01-06
--- /dev/null
+--TEST--
+Bug #74057: wrong day when using "this week" in strtotime
+--FILE--
+<?php
+echo date("D Y-m-d", strtotime("saturday this week", strtotime("Sun 2017-01-01")))."\n";
+echo date("D Y-m-d", strtotime("saturday this week", strtotime("Mon 2017-01-02")))."\n";
+echo date("D Y-m-d", strtotime("saturday this week", strtotime("Tue 2017-01-03")))."\n";
+echo date("D Y-m-d", strtotime("saturday this week", strtotime("Wed 2017-01-04")))."\n";
+echo date("D Y-m-d", strtotime("saturday this week", strtotime("Thu 2017-01-05")))."\n";
+echo date("D Y-m-d", strtotime("saturday this week", strtotime("Fri 2017-01-06")))."\n";
+echo date("D Y-m-d", strtotime("saturday this week", strtotime("Sat 2017-01-07")))."\n";
+echo date("D Y-m-d", strtotime("saturday this week", strtotime("Sun 2017-01-08")))."\n";
+echo date("D Y-m-d", strtotime("saturday this week", strtotime("Mon 2017-01-09")))."\n";
+?>
+--EXPECT--
+Sat 2016-12-31
+Sat 2017-01-07
+Sat 2017-01-07
+Sat 2017-01-07
+Sat 2017-01-07
+Sat 2017-01-07
+Sat 2017-01-07
+Sat 2017-01-07
+Sat 2017-01-14