Fix timezone issues.

This commit is contained in:
James Cole 2020-07-11 08:16:31 +02:00
parent 5cfe02edf6
commit 86600d4fcf
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D
2 changed files with 6 additions and 6 deletions

View File

@ -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;

View File

@ -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;
}