Skip to content

Commit cf61536

Browse files
authored
default first day of week to Sunday (#113)
1 parent 0a1f293 commit cf61536

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ServiceProvider.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,18 @@ private function bootCarbon(): self
5656
{
5757
Carbon::setLocale(Site::current()->locale());
5858

59-
$weekStartDay = Carbon::getTranslator()->trans(id: 'first_day_of_week', locale: Site::current()->locale());
60-
6159
/*
6260
Using these deprecated methods because I couldn't figure out another way to
6361
have the weekstart set based on the current locale.
6462
6563
When the next version of Carbon is released, it should be set properly: https://github.com/briannesbitt/Carbon/issues/2539#issuecomment-1037257768
6664
6765
*/
66+
67+
if (is_string($weekStartDay = Carbon::getTranslator()->trans(id: 'first_day_of_week', locale: Site::current()->locale()))) {
68+
$weekStartDay = 0;
69+
}
70+
6871
Carbon::setWeekStartsAt(day: $weekStartDay);
6972
Carbon::setWeekEndsAt(day: ($weekStartDay + 6) % 7);
7073

0 commit comments

Comments
 (0)