Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/WalletsController.php
Show First 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | protected function getWalletNotice(Wallet $wallet): ?string | ||||
return \trans('app.wallet-notice-today'); | return \trans('app.wallet-notice-today'); | ||||
} | } | ||||
// Once in a while we got e.g. "3 weeks" instead of expected "4 weeks". | // Once in a while we got e.g. "3 weeks" instead of expected "4 weeks". | ||||
// It's because $until uses full seconds, but $now is more precise. | // It's because $until uses full seconds, but $now is more precise. | ||||
// We make sure both have the same time set. | // We make sure both have the same time set. | ||||
$now = Carbon::now()->setTimeFrom($until); | $now = Carbon::now()->setTimeFrom($until); | ||||
$diffOptions = [ | |||||
'syntax' => Carbon::DIFF_ABSOLUTE, | |||||
'parts' => 1, | |||||
]; | |||||
if ($now->diff($until)->days > 31) { | |||||
$diffOptions['parts'] = 2; | |||||
} | |||||
$params = [ | $params = [ | ||||
'date' => $until->toDateString(), | 'date' => $until->toDateString(), | ||||
'days' => $now->diffForHumans($until, Carbon::DIFF_ABSOLUTE), | 'days' => $now->diffForHumans($until, $diffOptions), | ||||
]; | ]; | ||||
return \trans('app.wallet-notice-date', $params); | return \trans('app.wallet-notice-date', $params); | ||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
} | } |