Skip to content

Commit

Permalink
ensure run at is always returned to the front end in UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Nov 29, 2024
1 parent 17353de commit 691e51a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Livewire/Concerns/RemembersQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trait RemembersQueries
public function remember(callable $query, string $key = '', DateTimeInterface|DateInterval|Closure|int|null $ttl = 5): array
{
return App::make(CacheStoreResolver::class)->store()->remember('laravel:pulse:'.static::class.':'.$key.':'.$this->period, $ttl, function () use ($query) {
$start = CarbonImmutable::now()->toDateTimeString();
$start = CarbonImmutable::now('UTC')->toDateTimeString();

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

Expand Down
16 changes: 16 additions & 0 deletions tests/Feature/Livewire/RemembersQueriesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Illuminate\Support\Carbon;
use Laravel\Pulse\Livewire\SlowQueries;
use Livewire\Livewire;

it('always returns the run at date in UTC time', function () {
date_default_timezone_set('Australia/Melbourne');
Carbon::setTestNow(Carbon::createFromFormat('Y-m-d H:i:s', '2000-01-01 13:00:00', 'UTC'));

Livewire::test(SlowQueries::class, ['lazy' => false, 'disableHighlighting' => true])
->assertSeeHtml(<<<'HTML'
Run at: ${formatDate(&#039;2000-01-01 13:00:00&#039;)}
HTML);
});

0 comments on commit 691e51a

Please sign in to comment.