Skip to content

Commit 8e0107f

Browse files
authored
[1.x] Ensure run at is always returned to the front end in UTC (#425)
* ensure run at is always returned to the front end in UTC * Fix code styling --------- Co-authored-by: timacdonald <[email protected]>
1 parent 17353de commit 8e0107f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Livewire/Concerns/RemembersQueries.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ trait RemembersQueries
2020
public function remember(callable $query, string $key = '', DateTimeInterface|DateInterval|Closure|int|null $ttl = 5): array
2121
{
2222
return App::make(CacheStoreResolver::class)->store()->remember('laravel:pulse:'.static::class.':'.$key.':'.$this->period, $ttl, function () use ($query) {
23-
$start = CarbonImmutable::now()->toDateTimeString();
23+
$start = CarbonImmutable::now('UTC')->toDateTimeString();
2424

2525
[$value, $duration] = Benchmark::value(fn () => $query($this->periodAsInterval()));
2626

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
use Illuminate\Support\Carbon;
4+
use Laravel\Pulse\Livewire\SlowQueries;
5+
use Livewire\Livewire;
6+
7+
it('always returns the run at date in UTC time', function () {
8+
date_default_timezone_set('Australia/Melbourne');
9+
Carbon::setTestNow(Carbon::createFromFormat('Y-m-d H:i:s', '2000-01-01 13:00:00', 'UTC'));
10+
11+
Livewire::test(SlowQueries::class, ['lazy' => false, 'disableHighlighting' => true])
12+
->assertSeeHtml(<<<'HTML'
13+
Run at: ${formatDate(&#039;2000-01-01 13:00:00&#039;)}
14+
HTML);
15+
});

0 commit comments

Comments
 (0)