Skip to content

Commit a82c083

Browse files
authored
Merge pull request #803 from DirectoryTree/bug-801
Fix date attributes producing invalid UNIX timestamps on 32-bit PHP
2 parents c8171fb + 2a05910 commit a82c083

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/Models/Attributes/Timestamp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ protected function convertWindowsIntegerTimeToDateTime(string|int|null $value =
190190
}
191191

192192
return (new DateTime)->setTimestamp(
193-
(int) ($value / 10000000) - 11644473600
193+
(int) (round($value / 10000000) - 11644473600)
194194
);
195195
}
196196

tests/Unit/Models/Attributes/TimestampTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function test_windows_int_type_rounds_correctly()
154154
foreach (['133692539995000000', '133692539999500000'] as $windowsIntegerTime) {
155155
$dateTime = $timestamp->toDateTime($windowsIntegerTime);
156156

157-
$expectedUnixTimestamp = (int) ($windowsIntegerTime / 10000000) - 11644473600;
157+
$expectedUnixTimestamp = (int) (round($windowsIntegerTime / 10000000) - 11644473600);
158158

159159
$this->assertEquals($expectedUnixTimestamp, $dateTime->getTimestamp());
160160
}

0 commit comments

Comments
 (0)