This commit is contained in:
2021-10-22 23:10:23 +02:00
parent ec2617b9d6
commit cdecdf41fa
8 changed files with 296 additions and 38 deletions

View File

@@ -22,19 +22,10 @@ export const FormatDate = (date) => {
const matchDate = DateTime.fromSeconds(date || 0)
const diff = DateTime.now().diff(matchDate)
if (diff.as('days') > 10)
if (diff.as('days') > 8)
return matchDate.toLocaleString({weekday: 'short', day: '2-digit', month: '2-digit', year: 'numeric'})
else if (diff.as('days') < 1)
if (diff.as('hours') < 1)
return Math.floor(diff.as('minutes')) + ' minutes ago'
else if (Math.floor(diff.as('hours')) === 1)
return Math.floor(diff.as('hours')) + ' hour ago'
else
return Math.floor(diff.as('hours')) + ' hours ago'
else if (Math.floor(diff.as('days')) === 1)
return Math.floor(diff.as('days')) + ' day ago'
else
return Math.floor(diff.as('days')) + ' days ago'
return matchDate.toRelative()
}
export const FormatFullDate = (date) => {
@@ -50,3 +41,14 @@ export const FormatFullDate = (date) => {
second: '2-digit'
})
}
export const FormatVacDate = (date, match) => {
const vacDate = DateTime.fromSeconds(date || 0)
const matchDate = DateTime.fromSeconds(match || 0)
if (vacDate.diff(matchDate).as('days') >= -30) {
return vacDate.toRelative()
} else {
return ''
}
}