From 9fdaf1cee8330f47c115a02612e3d8c7dce297a4 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 6 Jan 2023 21:12:10 +0100 Subject: [PATCH] Fix https://github.com/firefly-iii/firefly-iii/issues/6810 --- app/Factory/TransactionJournalFactory.php | 10 +++++++++- app/Support/Request/ConvertsDataTypes.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index 3ac8ba5503..662a3d3b8b 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Factory; +use Carbon\Carbon; use Exception; use FireflyIII\Exceptions\DuplicateTransactionException; use FireflyIII\Exceptions\FireflyException; @@ -219,6 +220,8 @@ class TransactionJournalFactory $foreignCurrency = $this->getForeignByAccount($type->type, $foreignCurrency, $destinationAccount); $description = $this->getDescription($description); + Log::debug(sprintf('Date: %s (%s)', $carbon->toW3cString(), $carbon->getTimezone()->getName())); + /** Create a basic journal. */ $journal = TransactionJournal::create( [ @@ -601,8 +604,13 @@ class TransactionJournalFactory 'name' => $field, 'data' => (string)($data[$field] ?? ''), ]; + if ($data[$field] instanceof Carbon) { + $data[$field]->setTimezone(config('app.timezone')); + Log::debug(sprintf('%s Date: %s (%s)', $field, $data[$field], $data[$field]->timezone->getName())); + $set['data'] = $data[$field]->format('Y-m-d H:i:s'); + } - //Log::debug(sprintf('Going to store meta-field "%s", with value "%s".', $set['name'], $set['data'])); + Log::debug(sprintf('Going to store meta-field "%s", with value "%s".', $set['name'], $set['data'])); /** @var TransactionJournalMetaFactory $factory */ $factory = app(TransactionJournalMetaFactory::class); diff --git a/app/Support/Request/ConvertsDataTypes.php b/app/Support/Request/ConvertsDataTypes.php index dd42093623..17d217d10f 100644 --- a/app/Support/Request/ConvertsDataTypes.php +++ b/app/Support/Request/ConvertsDataTypes.php @@ -236,7 +236,7 @@ trait ConvertsDataTypes } $carbon = null; try { - $carbon = new Carbon($string); + $carbon = new Carbon($string, config('app.timezone')); } catch (InvalidFormatException $e) { // @ignoreException }