Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Playing around with local date time parsing.
James Cole0ae5593dded9
diff --git a/app/Casts/SeparateTimezoneCaster.php b/app/Casts/SeparateTimezoneCaster.phpindex ef12471230..726a667c67 100644--- a/app/Casts/SeparateTimezoneCaster.php+++ b/app/Casts/SeparateTimezoneCaster.php@@ -3,7 +3,6 @@namespace FireflyIII\Casts;use Carbon\Carbon;-use Carbon\CarbonImmutable;use Illuminate\Contracts\Database\Eloquent\CastsAttributes;use Illuminate\Database\Eloquent\Model;@@ -19,13 +18,11 @@ use Illuminate\Database\Eloquent\Model;class SeparateTimezoneCaster implements CastsAttributes{/**- * Cast the given value.- ** @param array<string, mixed> $attributes*/public function get(Model $model, string $key, mixed $value, array $attributes): ?Carbon{- if('' === $value || null === $value) {+ if ('' === $value || null === $value) {return null;}$timeZone = $attributes[sprintf('%s_tz', $key)] ?? config('app.timezone');diff --git a/public/v1/js/ff/firefly.js b/public/v1/js/ff/firefly.jsindex 00a07b80ea..e7d8fa2041 100644--- a/public/v1/js/ff/firefly.js+++ b/public/v1/js/ff/firefly.js@@ -26,6 +26,16 @@ $.ajaxSetup({}});+function parseToLocalDates() {+ "use strict";+ $('span.date-time').each(function () {+ var date = $(this).data('date');+ var obj = moment.utc(date).local();+ var timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;+ $(this).text(obj.format(date_time_js) + ' ('+ timeZone +')');+ });+}+$(function () {"use strict";@@ -96,6 +106,9 @@ $(function () {// trigger list thinglistLengthInitial();+ // update dates:+ parseToLocalDates();+});function currencySelect(e) {diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex 7cf8cd83df..55e48a4bc1 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -26,6 +26,7 @@ declare(strict_types=1);return [// general stuff:+ 'stored_as_tz' => 'stored as ":timezone"','close' => 'Close','actions' => 'Actions','edit' => 'Edit',diff --git a/resources/views/javascript/variables.twig b/resources/views/javascript/variables.twigindex a6676011ff..37c6ab8c13 100644--- a/resources/views/javascript/variables.twig+++ b/resources/views/javascript/variables.twig@@ -44,6 +44,7 @@ var todayText = ' {{ trans('firefly.today')|escape('js') }}';// some formatting stuff:var month_and_day_js = "{{ trans('config.month_and_day_js') }}";+var date_time_js = "{{ trans('config.date_time_js') }}";var acc_config_new = {format: accountingConfig};// strings and translations used often:diff --git a/resources/views/transactions/show.twig b/resources/views/transactions/show.twigindex 82307440a7..b4992e28a8 100644--- a/resources/views/transactions/show.twig+++ b/resources/views/transactions/show.twig@@ -74,10 +74,12 @@<tr><td style="width:30%;">{{ trans('list.date') }}</td><td>+ <span class="date-time" data-date="{{ first.date.toIso8601ZuluString() }}">{{ first.date.isoFormat(dateTimeFormat) }}{% if(first.date_tz != '') %}- ({{ first.date_tz }})+ ({{ trans('firefly.stored_as_tz', {timezone: first.date_tz }) }}){% endif %}+ </span></td></tr></tbody>