Skip to content

[6.x] Remove use of deprecated nesbot/carbon methods #106

@tom-oneshotdigital

Description

@tom-oneshotdigital

Carbon::setWeekStartsAt() && Carbon::setWeekEndsAt() are deprecated and have been removed from Carbon v3.0. Statamic v5.x supports either "^2.62.1 || ^3.0" but if 3.0 is installed then these lines from the service provider throw

Carbon::setWeekStartsAt(day: $weekStartDay);

Carbon\Exceptions\UnknownMethodException 
 
   Method Illuminate\Support\Carbon::setWeekStartsAt does not exist.
 
   at vendor/nesbot/carbon/src/Carbon/Traits/Date.php:2484
     2480▕                 }
     2481▕             }
     2482▕ 
     2483▕             if (static::isStrictModeEnabled()) {
   ➜ 2484▕                 throw new UnknownMethodException(\sprintf('%s::%s', static::class, $method));
     2485▕             }
     2486▕ 
     2487▕             return null;
     2488▕         }
 
       +12 vendor frames 
 
   13  artisan:13
       Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))
 
 Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

This is the commentary in the upgrade to carbon 3 documentation https://carbon.nesbot.com/docs/#api-carbon-3

setWeekStartsAt and setWeekEndsAt are also removed. You should either specify the day explictly when calling startOfWeek, for instance: ->startOfWeek(\Carbon\WeekDay::Wednesday) or change the locale appriopriately, for instance ->locale('en_US')->startOfWeek() goes to Sunday, while ->locale('en_GB')->startOfWeek() goes to Monday, ar_EG locale sets it to Saturday, etc.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions