From 86600d4fcf1c7df70ce86ea6b63267542bb0b437 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 11 Jul 2020 08:16:31 +0200 Subject: [PATCH] Fix timezone issues. --- app/Http/Middleware/Range.php | 5 +++-- app/Support/Steam.php | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php index 1d273c8124..d847587b2e 100644 --- a/app/Http/Middleware/Range.php +++ b/app/Http/Middleware/Range.php @@ -114,7 +114,8 @@ class Range // ignore preference. set the range to be the current month: if (!app('session')->has('start') && !app('session')->has('end')) { $viewRange = app('preferences')->get('viewRange', '1M')->data; - $start = app('navigation')->updateStartDate($viewRange, new Carbon); + $today = today(config('app.timezone')); + $start = app('navigation')->updateStartDate($viewRange, $today); $end = app('navigation')->updateEndDate($viewRange, $start); app('session')->put('start', $start); @@ -124,7 +125,7 @@ class Range /** @var JournalRepositoryInterface $repository */ $repository = app(JournalRepositoryInterface::class); $journal = $repository->firstNull(); - $first = Carbon::now()->startOfYear(); + $first = today(config('app.timezone'))->startOfYear(); if (null !== $journal) { $first = $journal->date ?? $first; diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 0842414269..42caf4021c 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -234,18 +234,17 @@ class Steam $modified = null === $entry->modified ? '0' : (string)$entry->modified; $foreignModified = null === $entry->modified_foreign ? '0' : (string)$entry->modified_foreign; $amount = '0'; - if ($currencyId === (int)$entry->transaction_currency_id || 0 === $currencyId) { + if ($currencyId === (int) $entry->transaction_currency_id || 0 === $currencyId) { // use normal amount: $amount = $modified; } - if ($currencyId === (int)$entry->foreign_currency_id) { + if ($currencyId === (int) $entry->foreign_currency_id) { // use foreign amount: $amount = $foreignModified; } $currentBalance = bcadd($currentBalance, $amount); - $carbon = new Carbon($entry->date, 'UTC'); - $carbon->setTimezone(env('TZ')); + $carbon = new Carbon($entry->date, config('app.timezone')); $date = $carbon->format('Y-m-d'); $balances[$date] = $currentBalance; }