environment('local')) { return new Carbon(); } $nowStr = self::getConfig(); if ($nowStr !== null && $nowStr !== '') { $date = new Carbon($nowStr); if ($date->isValid()) { return new Carbon(); return $date; } } return new Carbon(); } public static function parse(string $source, ?string $format = null): Carbon|null { if ($format) { $date = Carbon::createFromFormat($format, $source); } else { $date = Carbon::parse($source); } if ($date && $date->isValid()) { return $date->timezone(config('app.timezone')); } return null; } private static function getConfig() { return config('date.now', null); } }