From 65754408773eb90710adacd238c96542eff59e79 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 7 Apr 2022 17:20:12 +0200 Subject: [PATCH] Bugfix/fix dates in value component (#810) * Fix dates * Update changelog --- CHANGELOG.md | 6 ++++++ .../position-detail-dialog.html | 2 ++ libs/ui/src/lib/value/value.component.ts | 17 ++++++++--------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a948fc24a..5d03715a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Fixed an issue with dates in the value component + ## 1.132.1 - 06.04.2022 ### Fixed diff --git a/apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html b/apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html index b5b10f3c9..c832c07b1 100644 --- a/apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html +++ b/apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html @@ -111,6 +111,8 @@ diff --git a/libs/ui/src/lib/value/value.component.ts b/libs/ui/src/lib/value/value.component.ts index 08fdb413e..2004065db 100644 --- a/libs/ui/src/lib/value/value.component.ts +++ b/libs/ui/src/lib/value/value.component.ts @@ -5,7 +5,6 @@ import { OnChanges } from '@angular/core'; import { getLocale } from '@ghostfolio/common/helper'; -import { isDate, parseISO } from 'date-fns'; import { isNumber } from 'lodash'; @Component({ @@ -19,6 +18,7 @@ export class ValueComponent implements OnChanges { @Input() currency = ''; @Input() isAbsolute = false; @Input() isCurrency = false; + @Input() isDate = false; @Input() isPercent = false; @Input() label = ''; @Input() locale = getLocale(); @@ -100,17 +100,16 @@ export class ValueComponent implements OnChanges { this.isNumber = false; this.isString = true; - try { - if (isDate(parseISO(this.value))) { - this.formattedValue = new Date( - this.value - ).toLocaleDateString(this.locale, { + if (this.isDate) { + this.formattedValue = new Date(this.value).toLocaleDateString( + this.locale, + { day: '2-digit', month: '2-digit', year: 'numeric' - }); - } - } catch { + } + ); + } else { this.formattedValue = this.value; } }