From 9153be489ce5fee28b6e5de777cd75c73593e0f1 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 1 Jan 2025 09:47:27 -0800 Subject: [PATCH] Fix: tweak relative date --- src-ui/messages.xlf | 30 ++++++++----------- src-ui/src/app/pipes/custom-date.pipe.spec.ts | 6 ++-- src-ui/src/app/pipes/custom-date.pipe.ts | 8 ++--- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index 314910f5d..7535206a4 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -3462,6 +3462,10 @@ src/app/components/common/dates-dropdown/dates-dropdown.component.ts 53 + + src/app/pipes/custom-date.pipe.ts + 19 + Last 3 months @@ -3476,6 +3480,10 @@ src/app/components/common/dates-dropdown/dates-dropdown.component.ts 63 + + src/app/pipes/custom-date.pipe.ts + 14 + Matching algorithm @@ -9101,13 +9109,6 @@ 36 - - %s year ago - - src/app/pipes/custom-date.pipe.ts - 14 - - %s years ago @@ -9115,13 +9116,6 @@ 15 - - %s month ago - - src/app/pipes/custom-date.pipe.ts - 19 - - %s months ago @@ -9129,8 +9123,8 @@ 20 - - %s week ago + + Last week src/app/pipes/custom-date.pipe.ts 24 @@ -9143,8 +9137,8 @@ 25 - - %s day ago + + Yesterday src/app/pipes/custom-date.pipe.ts 29 diff --git a/src-ui/src/app/pipes/custom-date.pipe.spec.ts b/src-ui/src/app/pipes/custom-date.pipe.spec.ts index 758c52d54..901b1048d 100644 --- a/src-ui/src/app/pipes/custom-date.pipe.spec.ts +++ b/src-ui/src/app/pipes/custom-date.pipe.spec.ts @@ -39,10 +39,12 @@ describe('CustomDatePipe', () => { const now = new Date() const notNow = new Date(now) notNow.setDate(now.getDate() - 1) - expect(datePipe.transform(notNow, 'relative')).toEqual('1 day ago') + expect(datePipe.transform(notNow, 'relative')).toEqual('Yesterday') notNow.setDate(now.getDate()) notNow.setMonth(now.getMonth() - 1) - expect(datePipe.transform(notNow, 'relative')).toEqual('1 month ago') + expect(datePipe.transform(notNow, 'relative')).toEqual( + now.getMonth() > 1 ? 'Last month' : 'Last year' + ) expect(datePipe.transform(now, 'relative')).toEqual('Just now') }) }) diff --git a/src-ui/src/app/pipes/custom-date.pipe.ts b/src-ui/src/app/pipes/custom-date.pipe.ts index a7a31a2ed..69e054a84 100644 --- a/src-ui/src/app/pipes/custom-date.pipe.ts +++ b/src-ui/src/app/pipes/custom-date.pipe.ts @@ -11,22 +11,22 @@ const FORMAT_TO_ISO_FORMAT = { const INTERVALS = { year: { - label: $localize`%s year ago`, + label: $localize`Last year`, labelPlural: $localize`%s years ago`, interval: 31536000, }, month: { - label: $localize`%s month ago`, + label: $localize`Last month`, labelPlural: $localize`%s months ago`, interval: 2592000, }, week: { - label: $localize`%s week ago`, + label: $localize`Last week`, labelPlural: $localize`%s weeks ago`, interval: 604800, }, day: { - label: $localize`%s day ago`, + label: $localize`Yesterday`, labelPlural: $localize`%s days ago`, interval: 86400, },