Fix: tweak relative date

This commit is contained in:
shamoon
2025-01-01 09:47:27 -08:00
parent 90731e05f5
commit 9153be489c
3 changed files with 20 additions and 24 deletions

View File

@@ -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')
})
})

View File

@@ -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,
},