mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
fix(#61): fix playlist midnight overlap
This commit is contained in:
parent
2056e2a2c2
commit
56a29e8aed
2 changed files with 146 additions and 3 deletions
|
|
@ -43,11 +43,22 @@ class Playlist extends Model
|
|||
return false;
|
||||
}
|
||||
}
|
||||
// Check time range
|
||||
|
||||
if ($this->active_from !== null && $this->active_until !== null) {
|
||||
if (! now()->between($this->active_from, $this->active_until)) {
|
||||
return false;
|
||||
$now = now();
|
||||
|
||||
// Handle time ranges that span across midnight
|
||||
if ($this->active_from > $this->active_until) {
|
||||
// Time range spans midnight (e.g., 09:01 to 03:58)
|
||||
if ($now >= $this->active_from || $now <= $this->active_until) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if ($now >= $this->active_from && $now <= $this->active_until) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue