style: adjust spacing

This commit is contained in:
csr4422
2025-10-03 13:09:00 +05:30
parent e4018ddab8
commit 4b8f30184a

View File

@@ -1,17 +1,17 @@
import { format, differenceInMinutes, differenceInHours, differenceInDays,differenceInMonths, differenceInYears } from 'date-fns' import { format, differenceInMinutes, differenceInHours, differenceInDays, differenceInMonths, differenceInYears } from 'date-fns'
export function getRelativeTime (timestamp, now = new Date()) { export function getRelativeTime (timestamp, now = new Date()) {
try { try {
const mins = differenceInMinutes(now, timestamp) const mins = differenceInMinutes(now, timestamp)
const hours = differenceInHours(now, timestamp) const hours = differenceInHours(now, timestamp)
const days = differenceInDays(now, timestamp) const days = differenceInDays(now, timestamp)
const months=differenceInMonths(now, timestamp) const months = differenceInMonths(now, timestamp)
const years = differenceInYears(now, timestamp) const years = differenceInYears(now, timestamp)
if (mins === 0) return 'now' if (mins === 0) return 'now'
if (mins < 60) return `${mins}m` if (mins < 60) return `${mins}m`
if (hours < 24) return `${hours}h` if (hours < 24) return `${hours}h`
if (days < 30) return `${days}d` if (days < 31) return `${days}d`
if (months < 12) return `${months}mo` if (months < 12) return `${months}mo`
return `${years}y` return `${years}y`
} catch (error) { } catch (error) {