File tree 2 files changed +5
-5
lines changed
src/Symfony/Component/Clock
2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -42,11 +42,11 @@ public function sleep(float|int $seconds): void
42
42
{
43
43
$ now = explode ('. ' , $ this ->now ->format ('U.u ' ));
44
44
45
- if (0 < $ s = ( int ) $ seconds ) {
45
+ if (0 < $ s = floor ( $ seconds) ) {
46
46
$ now [0 ] += $ s ;
47
47
}
48
48
49
- if (0 < ($ us = $ seconds - $ s ) && 1E6 <= $ now [1 ] += $ us * 1E6 ) {
49
+ if (0 < ($ us = $ seconds - $ s ) && 1E6 <= $ now [1 ] += round ( $ us * 1E6 ) ) {
50
50
++$ now [0 ];
51
51
$ now [1 ] -= 1E6 ;
52
52
}
Original file line number Diff line number Diff line change @@ -55,11 +55,11 @@ public function testNow()
55
55
56
56
public function testSleep ()
57
57
{
58
- $ clock = new MockClock ((new \DateTimeImmutable ('@123.456 ' ))->setTimezone (new \DateTimeZone ('UTC ' )));
58
+ $ clock = new MockClock ((new \DateTimeImmutable ('2112-09-17 23:53:00.999Z ' ))->setTimezone (new \DateTimeZone ('UTC ' )));
59
59
$ tz = $ clock ->now ()->getTimezone ()->getName ();
60
60
61
- $ clock ->sleep (4.999 );
62
- $ this ->assertSame ('128.455000 ' , $ clock ->now ()->format ('U .u ' ));
61
+ $ clock ->sleep (2.002001 );
62
+ $ this ->assertSame ('2112-09-17 23:53:03.001001 ' , $ clock ->now ()->format ('Y-m-d H:i:s .u ' ));
63
63
$ this ->assertSame ($ tz , $ clock ->now ()->getTimezone ()->getName ());
64
64
}
65
65
You can’t perform that action at this time.
0 commit comments