Skip to content

Commit

Permalink
Fix entry scheduling when app timezone isn't UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Feb 27, 2025
1 parent a139181 commit 9a029f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Jobs/HandleEntrySchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Support\Collection;
use Statamic\Entries\MinuteEntries;
use Statamic\Events\EntryScheduleReached;
use Statamic\Facades\Entry;

class HandleEntrySchedule implements ShouldQueue
{
Expand All @@ -25,7 +26,7 @@ private function entries(): Collection
// were scheduled for then would now be considered published. If we were targeting
// the current minute and the entry has defined a time with seconds later in the
// same minute, it may still be considered scheduled when it gets dispatched.
$minute = now()->subMinute();
$minute = now('UTC')->subMinute();

return (new MinuteEntries($minute))();
}
Expand Down
8 changes: 4 additions & 4 deletions src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,10 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and')
}

if (! ($value instanceof DateTimeInterface)) {
$value = Carbon::parse($value);
$value = Carbon::parse($value, 'UTC');
}

$value = Carbon::parse($value->format('Y-m-d')); // we only care about the date part
$value = Carbon::parse($value->format('Y-m-d'), 'UTC'); // we only care about the date part

$this->wheres[] = [
'type' => 'Date',
Expand Down Expand Up @@ -510,10 +510,10 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and')
}

if (! ($value instanceof DateTimeInterface)) {
$value = Carbon::parse($value);
$value = Carbon::parse($value, 'UTC');
}

$value = $value->format('H:i:s'); // we only care about the time part
$value = $value->format('H:i:s', 'UTC'); // we only care about the time part

$this->wheres[] = [
'type' => 'Time',
Expand Down

0 comments on commit 9a029f7

Please sign in to comment.