Bugfix/fix dates in value component (#810)
* Fix dates * Update changelog
This commit is contained in:
parent
255af6a6e9
commit
6575440877
@ -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/),
|
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).
|
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
|
## 1.132.1 - 06.04.2022
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -111,6 +111,8 @@
|
|||||||
<gf-value
|
<gf-value
|
||||||
label="First Buy Date"
|
label="First Buy Date"
|
||||||
size="medium"
|
size="medium"
|
||||||
|
[isDate]="true"
|
||||||
|
[locale]="data.locale"
|
||||||
[value]="firstBuyDate"
|
[value]="firstBuyDate"
|
||||||
></gf-value>
|
></gf-value>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,7 +5,6 @@ import {
|
|||||||
OnChanges
|
OnChanges
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { getLocale } from '@ghostfolio/common/helper';
|
import { getLocale } from '@ghostfolio/common/helper';
|
||||||
import { isDate, parseISO } from 'date-fns';
|
|
||||||
import { isNumber } from 'lodash';
|
import { isNumber } from 'lodash';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -19,6 +18,7 @@ export class ValueComponent implements OnChanges {
|
|||||||
@Input() currency = '';
|
@Input() currency = '';
|
||||||
@Input() isAbsolute = false;
|
@Input() isAbsolute = false;
|
||||||
@Input() isCurrency = false;
|
@Input() isCurrency = false;
|
||||||
|
@Input() isDate = false;
|
||||||
@Input() isPercent = false;
|
@Input() isPercent = false;
|
||||||
@Input() label = '';
|
@Input() label = '';
|
||||||
@Input() locale = getLocale();
|
@Input() locale = getLocale();
|
||||||
@ -100,17 +100,16 @@ export class ValueComponent implements OnChanges {
|
|||||||
this.isNumber = false;
|
this.isNumber = false;
|
||||||
this.isString = true;
|
this.isString = true;
|
||||||
|
|
||||||
try {
|
if (this.isDate) {
|
||||||
if (isDate(parseISO(this.value))) {
|
this.formattedValue = new Date(<string>this.value).toLocaleDateString(
|
||||||
this.formattedValue = new Date(
|
this.locale,
|
||||||
<string>this.value
|
{
|
||||||
).toLocaleDateString(this.locale, {
|
|
||||||
day: '2-digit',
|
day: '2-digit',
|
||||||
month: '2-digit',
|
month: '2-digit',
|
||||||
year: 'numeric'
|
year: 'numeric'
|
||||||
});
|
}
|
||||||
}
|
);
|
||||||
} catch {
|
} else {
|
||||||
this.formattedValue = this.value;
|
this.formattedValue = this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user