aboutsummaryrefslogtreecommitdiff
path: root/src/services/date_utils/date_utils.js
diff options
context:
space:
mode:
authorIlja <ilja@ilja.space>2022-07-18 12:33:03 +0200
committerIlja <ilja@ilja.space>2022-07-18 12:42:40 +0200
commit18d69f93d38dc15a74db81ee4c10b4766bebfc35 (patch)
tree56763764de2ef984f498d3507c6ebead3099c57d /src/services/date_utils/date_utils.js
parente594252668256197d9b68f1db1f7108c5255d275 (diff)
parent9ddb43296f3fbb6621e646a20e86e05b6c730ad2 (diff)
Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma-fe into feat/report-notification
Diffstat (limited to 'src/services/date_utils/date_utils.js')
-rw-r--r--src/services/date_utils/date_utils.js16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/services/date_utils/date_utils.js b/src/services/date_utils/date_utils.js
index 32e13bca..677c184c 100644
--- a/src/services/date_utils/date_utils.js
+++ b/src/services/date_utils/date_utils.js
@@ -10,31 +10,29 @@ export const relativeTime = (date, nowThreshold = 1) => {
if (typeof date === 'string') date = Date.parse(date)
const round = Date.now() > date ? Math.floor : Math.ceil
const d = Math.abs(Date.now() - date)
- let r = { num: round(d / YEAR), key: 'time.years' }
+ let r = { num: round(d / YEAR), key: 'time.unit.years' }
if (d < nowThreshold * SECOND) {
r.num = 0
r.key = 'time.now'
} else if (d < MINUTE) {
r.num = round(d / SECOND)
- r.key = 'time.seconds'
+ r.key = 'time.unit.seconds'
} else if (d < HOUR) {
r.num = round(d / MINUTE)
- r.key = 'time.minutes'
+ r.key = 'time.unit.minutes'
} else if (d < DAY) {
r.num = round(d / HOUR)
- r.key = 'time.hours'
+ r.key = 'time.unit.hours'
} else if (d < WEEK) {
r.num = round(d / DAY)
- r.key = 'time.days'
+ r.key = 'time.unit.days'
} else if (d < MONTH) {
r.num = round(d / WEEK)
- r.key = 'time.weeks'
+ r.key = 'time.unit.weeks'
} else if (d < YEAR) {
r.num = round(d / MONTH)
- r.key = 'time.months'
+ r.key = 'time.unit.months'
}
- // Remove plural form when singular
- if (r.num === 1) r.key = r.key.slice(0, -1)
return r
}