Skip to content

Commit c307c5f

Browse files
michalsnpaulbalandanneznaika0
authored
refactor: debugbar time header not dependent on locale (#9880)
Co-authored-by: John Paul E. Balandan, CPA <paulbalandan@gmail.com> Co-authored-by: neznaika0 <ozornick.ks@gmail.com>
1 parent 11f0130 commit c307c5f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

system/Debug/Toolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public function prepare(?RequestInterface $request = null, ?ResponseInterface $r
397397
helper('filesystem');
398398

399399
// Updated to microtime() so we can get history
400-
$time = sprintf('%.6f', Time::now()->format('U.u'));
400+
$time = sprintf('%.6F', Time::now()->format('U.u'));
401401

402402
if (! is_dir(WRITEPATH . 'debugbar')) {
403403
mkdir(WRITEPATH . 'debugbar', 0777);

system/Debug/Toolbar/Collectors/History.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function setFiles(string $current, int $limit = 20)
9090
$contents = @json_decode($contents);
9191
if (json_last_error() === JSON_ERROR_NONE) {
9292
preg_match('/debugbar_(.*)\.json$/s', $filename, $time);
93-
$time = sprintf('%.6f', $time[1] ?? 0);
93+
$time = sprintf('%.6F', $time[1] ?? 0);
9494

9595
// Debugbar files shown in History Collector
9696
$files[] = [

tests/system/Debug/Toolbar/Collectors/HistoryTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function setUp(): void
3434
{
3535
parent::setUp();
3636

37-
$this->time = (float) sprintf('%.6f', microtime(true));
37+
$this->time = (float) sprintf('%.6F', microtime(true));
3838
}
3939

4040
protected function tearDown(): void
@@ -63,9 +63,9 @@ private function createDummyDebugbarJson(): void
6363

6464
// create 20 dummy debugbar json files
6565
for ($i = 0; $i < 20; $i++) {
66-
$path = str_replace((string) $time, sprintf('%.6f', $time - self::STEP), $path);
66+
$path = str_replace((string) $time, sprintf('%.6F', $time - self::STEP), $path);
6767
file_put_contents($path, json_encode($dummyData));
68-
$time = sprintf('%.6f', $time - self::STEP);
68+
$time = sprintf('%.6F', $time - self::STEP);
6969
}
7070
}
7171

@@ -76,7 +76,7 @@ public function testSetFiles(): void
7676
// test dir is now populated with json
7777
$this->createDummyDebugbarJson();
7878

79-
$activeRowTime = $time = sprintf('%.6f', $time - self::STEP);
79+
$activeRowTime = $time = sprintf('%.6F', $time - self::STEP);
8080

8181
$history = new History();
8282
$history->setFiles($time, 20);
@@ -85,14 +85,14 @@ public function testSetFiles(): void
8585
$this->assertNotEmpty($history->display()['files'], 'Dummy Debugbar data is empty');
8686

8787
foreach ($history->display()['files'] as $request) {
88-
$this->assertSame($request['time'], sprintf('%.6f', $time));
88+
$this->assertSame($request['time'], sprintf('%.6F', $time));
8989
$this->assertSame(
9090
$request['datetime'],
9191
DateTime::createFromFormat('U.u', $time)->format('Y-m-d H:i:s.u'),
9292
);
9393
$this->assertSame($request['active'], ($time === $activeRowTime));
9494

95-
$time = sprintf('%.6f', $time - self::STEP);
95+
$time = sprintf('%.6F', $time - self::STEP);
9696
}
9797
}
9898
}

0 commit comments

Comments
 (0)