diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf
index eaa2d7bfe..134905485 100644
--- a/src-ui/messages.xlf
+++ b/src-ui/messages.xlf
@@ -7388,95 +7388,95 @@
36
-
- Just now
+
+ %s year ago
+
+ src/app/pipes/custom-date.pipe.ts
+ 14
+
+
+
+ %s years ago
+
+ src/app/pipes/custom-date.pipe.ts
+ 15
+
+
+
+ %s month ago
+
+ src/app/pipes/custom-date.pipe.ts
+ 19
+
+
+
+ %s months ago
+
+ src/app/pipes/custom-date.pipe.ts
+ 20
+
+
+
+ %s week ago
+
+ src/app/pipes/custom-date.pipe.ts
+ 24
+
+
+
+ %s weeks ago
+
+ src/app/pipes/custom-date.pipe.ts
+ 25
+
+
+
+ %s day ago
+
+ src/app/pipes/custom-date.pipe.ts
+ 29
+
+
+
+ %s days ago
+
+ src/app/pipes/custom-date.pipe.ts
+ 30
+
+
+
+ %s hour ago
+
+ src/app/pipes/custom-date.pipe.ts
+ 34
+
+
+
+ %s hours ago
+
+ src/app/pipes/custom-date.pipe.ts
+ 35
+
+
+
+ %s minute ago
src/app/pipes/custom-date.pipe.ts
39
-
- year ago
+
+ %s minutes ago
src/app/pipes/custom-date.pipe.ts
- 42
+ 40
-
- years ago
+
+ Just now
src/app/pipes/custom-date.pipe.ts
- 43
-
-
-
- month ago
-
- src/app/pipes/custom-date.pipe.ts
- 47
-
-
-
- months ago
-
- src/app/pipes/custom-date.pipe.ts
- 48
-
-
-
- week ago
-
- src/app/pipes/custom-date.pipe.ts
- 52
-
-
-
- weeks ago
-
- src/app/pipes/custom-date.pipe.ts
- 53
-
-
-
- day ago
-
- src/app/pipes/custom-date.pipe.ts
- 57
-
-
-
- days ago
-
- src/app/pipes/custom-date.pipe.ts
- 58
-
-
-
- hour ago
-
- src/app/pipes/custom-date.pipe.ts
- 62
-
-
-
- hours ago
-
- src/app/pipes/custom-date.pipe.ts
- 63
-
-
-
- minute ago
-
- src/app/pipes/custom-date.pipe.ts
- 67
-
-
-
- minutes ago
-
- src/app/pipes/custom-date.pipe.ts
- 68
+ 72
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 87e99212b..ddc03c773 100644
--- a/src-ui/src/app/pipes/custom-date.pipe.spec.ts
+++ b/src-ui/src/app/pipes/custom-date.pipe.spec.ts
@@ -1,10 +1,7 @@
import { TestBed } from '@angular/core/testing'
import { CustomDatePipe } from './custom-date.pipe'
import { SettingsService } from '../services/settings.service'
-import {
- HttpClientTestingModule,
- HttpTestingController,
-} from '@angular/common/http/testing'
+import { HttpClientTestingModule } from '@angular/common/http/testing'
import { DatePipe } from '@angular/common'
describe('CustomDatePipe', () => {
diff --git a/src-ui/src/app/pipes/custom-date.pipe.ts b/src-ui/src/app/pipes/custom-date.pipe.ts
index e6034c59b..a7a31a2ed 100644
--- a/src-ui/src/app/pipes/custom-date.pipe.ts
+++ b/src-ui/src/app/pipes/custom-date.pipe.ts
@@ -9,6 +9,39 @@ const FORMAT_TO_ISO_FORMAT = {
shortDate: 'y-MM-dd',
}
+const INTERVALS = {
+ year: {
+ label: $localize`%s year ago`,
+ labelPlural: $localize`%s years ago`,
+ interval: 31536000,
+ },
+ month: {
+ label: $localize`%s month ago`,
+ labelPlural: $localize`%s months ago`,
+ interval: 2592000,
+ },
+ week: {
+ label: $localize`%s week ago`,
+ labelPlural: $localize`%s weeks ago`,
+ interval: 604800,
+ },
+ day: {
+ label: $localize`%s day ago`,
+ labelPlural: $localize`%s days ago`,
+ interval: 86400,
+ },
+ hour: {
+ label: $localize`%s hour ago`,
+ labelPlural: $localize`%s hours ago`,
+ interval: 3600,
+ },
+ minute: {
+ label: $localize`%s minute ago`,
+ labelPlural: $localize`%s minutes ago`,
+ interval: 60,
+ },
+}
+
@Pipe({
name: 'customDate',
})
@@ -37,45 +70,13 @@ export class CustomDatePipe implements PipeTransform {
if (format === 'relative') {
const seconds = Math.floor((+new Date() - +new Date(value)) / 1000)
if (seconds < 60) return $localize`Just now`
- const intervals = {
- year: {
- label: $localize`year ago`,
- labelPlural: $localize`years ago`,
- interval: 31536000,
- },
- month: {
- label: $localize`month ago`,
- labelPlural: $localize`months ago`,
- interval: 2592000,
- },
- week: {
- label: $localize`week ago`,
- labelPlural: $localize`weeks ago`,
- interval: 604800,
- },
- day: {
- label: $localize`day ago`,
- labelPlural: $localize`days ago`,
- interval: 86400,
- },
- hour: {
- label: $localize`hour ago`,
- labelPlural: $localize`hours ago`,
- interval: 3600,
- },
- minute: {
- label: $localize`minute ago`,
- labelPlural: $localize`minutes ago`,
- interval: 60,
- },
- }
let counter
- for (const i in intervals) {
- counter = Math.floor(seconds / intervals[i].interval)
+ for (const i in INTERVALS) {
+ counter = Math.floor(seconds / INTERVALS[i].interval)
if (counter > 0) {
const label =
- counter > 1 ? intervals[i].labelPlural : intervals[i].label
- return `${counter} ${label}`
+ counter > 1 ? INTERVALS[i].labelPlural : INTERVALS[i].label
+ return label.replace('%s', counter.toString())
}
}
}