From 533fda89ab7a11fd20ace91dab8f438957c53a34 Mon Sep 17 00:00:00 2001 From: edalzell Date: Tue, 22 Apr 2025 12:30:35 -0700 Subject: [PATCH] default first day of week to Sunday --- src/ServiceProvider.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 2b9445c..47f8bc8 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -56,8 +56,6 @@ private function bootCarbon(): self { Carbon::setLocale(Site::current()->locale()); - $weekStartDay = Carbon::getTranslator()->trans(id: 'first_day_of_week', locale: Site::current()->locale()); - /* Using these deprecated methods because I couldn't figure out another way to have the weekstart set based on the current locale. @@ -65,6 +63,11 @@ private function bootCarbon(): self When the next version of Carbon is released, it should be set properly: https://github.com/briannesbitt/Carbon/issues/2539#issuecomment-1037257768 */ + + if (is_string($weekStartDay = Carbon::getTranslator()->trans(id: 'first_day_of_week', locale: Site::current()->locale()))) { + $weekStartDay = 0; + } + Carbon::setWeekStartsAt(day: $weekStartDay); Carbon::setWeekEndsAt(day: ($weekStartDay + 6) % 7);