mirror of
https://github.com/prymitive/karma
synced 2026-05-05 03:16:51 +00:00
fix(ui): tweak DateFromNow output
This commit is contained in:
committed by
Łukasz Mierzwa
parent
6ec85d6ffb
commit
f1e5974cdb
@@ -7,8 +7,8 @@ import formatDistanceToNowStrict from "date-fns/formatDistanceToNowStrict";
|
||||
const formatLabel = (timestamp: string) => {
|
||||
const ts = parseISO(timestamp);
|
||||
const diff = differenceInSeconds(new Date(), ts);
|
||||
if (diff > 0 && diff < 60) return "a few seconds ago";
|
||||
if (diff < 0 && diff >= -60) return "in a few seconds";
|
||||
if (diff > 0 && diff < 45) return "a few seconds ago";
|
||||
if (diff < 0 && diff >= -45) return "in a few seconds";
|
||||
if (diff === 0) return "just now";
|
||||
return formatDistanceToNowStrict(ts, {
|
||||
addSuffix: true,
|
||||
|
||||
Reference in New Issue
Block a user