Files
site-profile/src/support/time.ts
Alex Lebens 405fdf297c
All checks were successful
renovate / renovate (push) Successful in 49s
test-build / guarddog (push) Successful in 1m8s
test-build / build (push) Successful in 3m24s
feat: replace timeago with dayjs
2026-03-12 12:35:23 -05:00

29 lines
606 B
TypeScript

import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
dayjs.extend(relativeTime);
function formatFromNow(date: Date | null): string {
if (!date) {
return 'none';
}
return dayjs(date).fromNow()
}
function formatDate(date: Date): string {
return new Date(date).toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
})
}
function formatShortDate(date: Date): string {
return new Date(date).toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
})
}
export { formatFromNow, formatDate, formatShortDate, };