From 2a059102e924e8b3a9175402f3683567d2191404 Mon Sep 17 00:00:00 2001 From: Steve Bauman Date: Sat, 2 May 2026 12:03:40 -0400 Subject: [PATCH] Round expression to prevent floats being given --- src/Models/Attributes/Timestamp.php | 2 +- tests/Unit/Models/Attributes/TimestampTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Models/Attributes/Timestamp.php b/src/Models/Attributes/Timestamp.php index 4046eb71..d03e106d 100644 --- a/src/Models/Attributes/Timestamp.php +++ b/src/Models/Attributes/Timestamp.php @@ -190,7 +190,7 @@ protected function convertWindowsIntegerTimeToDateTime(string|int|null $value = } return (new DateTime)->setTimestamp( - (int) ($value / 10000000) - 11644473600 + (int) (round($value / 10000000) - 11644473600) ); } diff --git a/tests/Unit/Models/Attributes/TimestampTest.php b/tests/Unit/Models/Attributes/TimestampTest.php index c852437a..a0678c10 100644 --- a/tests/Unit/Models/Attributes/TimestampTest.php +++ b/tests/Unit/Models/Attributes/TimestampTest.php @@ -154,7 +154,7 @@ public function test_windows_int_type_rounds_correctly() foreach (['133692539995000000', '133692539999500000'] as $windowsIntegerTime) { $dateTime = $timestamp->toDateTime($windowsIntegerTime); - $expectedUnixTimestamp = (int) ($windowsIntegerTime / 10000000) - 11644473600; + $expectedUnixTimestamp = (int) (round($windowsIntegerTime / 10000000) - 11644473600); $this->assertEquals($expectedUnixTimestamp, $dateTime->getTimestamp()); }