Replace direct calls to Carbon class.

This commit is contained in:
James Cole
2023-02-11 07:36:45 +01:00
parent 79e98cf8a2
commit c979cfcd89
44 changed files with 137 additions and 103 deletions

View File

@@ -191,7 +191,7 @@ class ExportData extends Command
*/
private function getDateParameter(string $field): Carbon
{
$date = Carbon::now()->subYear();
$date = today(config('app.timezone'))->subYear();
$error = false;
if (null !== $this->option($field)) {
try {
@@ -209,7 +209,7 @@ class ExportData extends Command
if (true === $error && 'start' === $field) {
$journal = $this->journalRepository->firstNull();
$date = null === $journal ? Carbon::now()->subYear() : $journal->date;
$date = null === $journal ? today(config('app.timezone'))->subYear() : $journal->date;
$date->startOfDay();
}

View File

@@ -282,7 +282,7 @@ class ApplyRules extends Command
private function verifyInputDates(): void
{
// parse start date.
$inputStart = Carbon::now()->startOfMonth();
$inputStart = today(config('app.timezone'))->startOfMonth();
$startString = $this->option('start_date');
if (null === $startString) {
/** @var JournalRepositoryInterface $repository */
@@ -298,7 +298,7 @@ class ApplyRules extends Command
}
// parse end date
$inputEnd = Carbon::now();
$inputEnd = today(config('app.timezone'));
$endString = $this->option('end_date');
if (null !== $endString && '' !== $endString) {
$inputEnd = Carbon::createFromFormat('Y-m-d', $endString);