Skip to content

Commit ef55bf7

Browse files
committed
Fixed bug GH-7758 (Problems with negative timestamps and fractions)
1 parent b510868 commit ef55bf7

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ PHP NEWS
55
- CLI:
66
. Fixed bug GH-8575 (CLI closes standard streams too early). (Levi Morrison)
77

8+
- Date:
9+
. Fixed bug GH-7758 (Problems with negative timestamps and fractions).
10+
(Derick, Ilija)
11+
812
- FPM:
913
. Fixed ACL build check on MacOS. (David Carlier)
1014
. Fixed bug #72185: php-fpm writes empty fcgi record causing nginx 502.

ext/date/tests/gh7758.phpt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
GH-7758 (Problems with negative timestamps and fractions)
3+
--FILE--
4+
<?php
5+
date_default_timezone_set('UTC');
6+
7+
foreach ([0.4, 0, -0.4, -1, -1.4] as $ts) {
8+
$date = new DateTime('@' . $ts);
9+
print_r($date);
10+
}
11+
?>
12+
--EXPECT--
13+
DateTime Object
14+
(
15+
[date] => 1970-01-01 00:00:00.400000
16+
[timezone_type] => 1
17+
[timezone] => +00:00
18+
)
19+
DateTime Object
20+
(
21+
[date] => 1970-01-01 00:00:00.000000
22+
[timezone_type] => 1
23+
[timezone] => +00:00
24+
)
25+
DateTime Object
26+
(
27+
[date] => 1969-12-31 23:59:59.600000
28+
[timezone_type] => 1
29+
[timezone] => +00:00
30+
)
31+
DateTime Object
32+
(
33+
[date] => 1969-12-31 23:59:59.000000
34+
[timezone_type] => 1
35+
[timezone] => +00:00
36+
)
37+
DateTime Object
38+
(
39+
[date] => 1969-12-31 23:59:58.600000
40+
[timezone_type] => 1
41+
[timezone] => +00:00
42+
)

0 commit comments

Comments
 (0)