File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
tests/Unit/Models/Attributes Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -190,7 +190,7 @@ protected function convertWindowsIntegerTimeToDateTime(string|int|null $value =
190190 }
191191
192192 return (new DateTime )->setTimestamp (
193- round ($ value / 10000000 ) - 11644473600
193+ ( int ) ($ value / 10000000 ) - 11644473600
194194 );
195195 }
196196
Original file line number Diff line number Diff line change @@ -146,4 +146,17 @@ public function test_windows_int_type_properly_handles_minimum()
146146 $ this ->assertSame ($ min , $ timestamp ->toDateTime ($ min ));
147147 $ this ->assertSame ($ min , $ timestamp ->toDateTime ((string ) $ min ));
148148 }
149+
150+ public function test_windows_int_type_rounds_correctly ()
151+ {
152+ $ timestamp = new Timestamp ('windows-int ' );
153+
154+ foreach (['133692539995000000 ' , '133692539999500000 ' ] as $ windowsIntegerTime ) {
155+ $ dateTime = $ timestamp ->toDateTime ($ windowsIntegerTime );
156+
157+ $ expectedUnixTimestamp = (int ) ($ windowsIntegerTime / 10000000 ) - 11644473600 ;
158+
159+ $ this ->assertEquals ($ expectedUnixTimestamp , $ dateTime ->getTimestamp ());
160+ }
161+ }
149162}
You can’t perform that action at this time.
0 commit comments