diff --git a/CHANGELOG.md b/CHANGELOG.md index 61c69f535..2ccfea63b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Improved the platform icon in the create or update platform dialog of the admin control +- Localized the durations of the coupon system - Improved the language localization for Catalan (`ca`) - Improved the language localization for Dutch (`nl`) - Improved the language localization for Italian (`it`) diff --git a/apps/client/src/app/components/admin-overview/admin-overview.component.ts b/apps/client/src/app/components/admin-overview/admin-overview.component.ts index 377dd5f20..bc0c657dd 100644 --- a/apps/client/src/app/components/admin-overview/admin-overview.component.ts +++ b/apps/client/src/app/components/admin-overview/admin-overview.component.ts @@ -12,6 +12,7 @@ import { PROPERTY_SYSTEM_MESSAGE, ghostfolioPrefix } from '@ghostfolio/common/config'; +import { getDateFnsLocale } from '@ghostfolio/common/helper'; import { Coupon, InfoItem, @@ -24,6 +25,7 @@ import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; import { MatSlideToggleChange } from '@angular/material/slide-toggle'; import { MatSnackBar } from '@angular/material/snack-bar'; import { + addMilliseconds, differenceInSeconds, formatDistanceToNowStrict, parseISO @@ -131,6 +133,15 @@ export class AdminOverviewComponent implements OnDestroy, OnInit { return ''; } + public formatStringValue(aStringValue: StringValue) { + return formatDistanceToNowStrict( + addMilliseconds(new Date(), ms(aStringValue)), + { + locale: getDateFnsLocale(this.user?.settings?.language) + } + ); + } + public onAddCoupon() { const coupons = [ ...this.coupons, diff --git a/apps/client/src/app/components/admin-overview/admin-overview.html b/apps/client/src/app/components/admin-overview/admin-overview.html index 246e5fe04..c47387f37 100644 --- a/apps/client/src/app/components/admin-overview/admin-overview.html +++ b/apps/client/src/app/components/admin-overview/admin-overview.html @@ -105,7 +105,9 @@ @for (coupon of coupons; track coupon) { {{ coupon.code }} - {{ coupon.duration }} + + {{ formatStringValue(coupon.duration) }} +