Skip to content

Commit

Permalink
Fixed bug GH-7758 (Problems with negative timestamps and fractions)
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed May 20, 2022
1 parent b510868 commit ef55bf7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ PHP NEWS
- CLI:
. Fixed bug GH-8575 (CLI closes standard streams too early). (Levi Morrison)

- Date:
. Fixed bug GH-7758 (Problems with negative timestamps and fractions).
(Derick, Ilija)

- FPM:
. Fixed ACL build check on MacOS. (David Carlier)
. Fixed bug #72185: php-fpm writes empty fcgi record causing nginx 502.
Expand Down
42 changes: 42 additions & 0 deletions ext/date/tests/gh7758.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--TEST--
GH-7758 (Problems with negative timestamps and fractions)
--FILE--
<?php
date_default_timezone_set('UTC');

foreach ([0.4, 0, -0.4, -1, -1.4] as $ts) {
$date = new DateTime('@' . $ts);
print_r($date);
}
?>
--EXPECT--
DateTime Object
(
[date] => 1970-01-01 00:00:00.400000
[timezone_type] => 1
[timezone] => +00:00
)
DateTime Object
(
[date] => 1970-01-01 00:00:00.000000
[timezone_type] => 1
[timezone] => +00:00
)
DateTime Object
(
[date] => 1969-12-31 23:59:59.600000
[timezone_type] => 1
[timezone] => +00:00
)
DateTime Object
(
[date] => 1969-12-31 23:59:59.000000
[timezone_type] => 1
[timezone] => +00:00
)
DateTime Object
(
[date] => 1969-12-31 23:59:58.600000
[timezone_type] => 1
[timezone] => +00:00
)

0 comments on commit ef55bf7

Please sign in to comment.