Merge branch 'PHP-7.0' into PHP-7.1

This commit is contained in:
Nikita Popov 2017-03-09 16:44:25 +01:00
commit 6635639b75
3 changed files with 47 additions and 8 deletions

3
NEWS
View File

@ -5,6 +5,9 @@ PHP NEWS
- Core:
. Fixed bug #74149 (static embed SAPI linkage error). (krakjoe)
- Date:
. Fixed bug #72096 (Swatch time value incorrect for dates before 1970). (mcq8)
- DOM:
. Fixed bug #74004 (LIBXML_NOWARNING flag ingnored on loadHTML*).
(somedaysummer)

View File

@ -1153,11 +1153,12 @@ static zend_string *date_format(char *format, size_t format_len, timelib_time *t
case 'a': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "pm" : "am"); break;
case 'A': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "PM" : "AM"); break;
case 'B': {
int retval = (((((long)t->sse)-(((long)t->sse) - ((((long)t->sse) % 86400) + 3600))) * 10) / 864);
while (retval < 0) {
retval += 1000;
int retval = ((((long)t->sse)-(((long)t->sse) - ((((long)t->sse) % 86400) + 3600))) * 10);
if (retval < 0) {
retval += 864000;
}
retval = retval % 1000;
/* Make sure to do this on a positive int to avoid rounding errors */
retval = (retval / 864) % 1000;
length = slprintf(buffer, 32, "%03d", retval);
break;
}
@ -1348,11 +1349,12 @@ PHPAPI int php_idate(char format, time_t ts, int localtime)
/* Swatch Beat a.k.a. Internet Time */
case 'B':
retval = (((((long)t->sse)-(((long)t->sse) - ((((long)t->sse) % 86400) + 3600))) * 10) / 864);
while (retval < 0) {
retval += 1000;
retval = ((((long)t->sse)-(((long)t->sse) - ((((long)t->sse) % 86400) + 3600))) * 10);
if (retval < 0) {
retval += 864000;
}
retval = retval % 1000;
/* Make sure to do this on a positive int to avoid rounding errors */
retval = (retval / 864) % 1000;
break;
/* time */

View File

@ -0,0 +1,34 @@
--TEST--
Bug #72096: Swatch time value incorrect for dates before 1970
--INI--
date.timezone=UTC
--FILE--
<?php
for ($unix = 1461283200; $unix <= 1461369600; $unix += 8000) {
echo "Time:", gmdate('Y-m-d H:i:s = B', $unix), PHP_EOL;
echo "Time:", gmdate('Y-m-d H:i:s = B', $unix - 82 * 365 * 24 * 3600), PHP_EOL;
}
?>
--EXPECT--
Time:2016-04-22 00:00:00 = 041
Time:1934-05-13 00:00:00 = 041
Time:2016-04-22 02:13:20 = 134
Time:1934-05-13 02:13:20 = 134
Time:2016-04-22 04:26:40 = 226
Time:1934-05-13 04:26:40 = 226
Time:2016-04-22 06:40:00 = 319
Time:1934-05-13 06:40:00 = 319
Time:2016-04-22 08:53:20 = 412
Time:1934-05-13 08:53:20 = 412
Time:2016-04-22 11:06:40 = 504
Time:1934-05-13 11:06:40 = 504
Time:2016-04-22 13:20:00 = 597
Time:1934-05-13 13:20:00 = 597
Time:2016-04-22 15:33:20 = 689
Time:1934-05-13 15:33:20 = 689
Time:2016-04-22 17:46:40 = 782
Time:1934-05-13 17:46:40 = 782
Time:2016-04-22 20:00:00 = 875
Time:1934-05-13 20:00:00 = 875
Time:2016-04-22 22:13:20 = 967
Time:1934-05-13 22:13:20 = 967