MCPcopy Create free account
hub / github.com/dailydotdev/apps / publishTimeLiveTimer

Function publishTimeLiveTimer

packages/shared/src/lib/dateFormat.ts:63–78  ·  view source on GitHub ↗
(
  value,
  now = new Date(),
)

Source from the content-addressed store, hash-verified

61): string => format(new Date(value), "d MMMM yyyy 'at' HH:mm");
62
63export const publishTimeLiveTimer: typeof publishTimeRelativeShort = (
64 value,
65 now = new Date(),
66) => {
67 const date = new Date(value);
68
69 const dt = (now.getTime() - date.getTime()) / 1000;
70
71 if (dt <= oneMinute) {
72 const numSeconds = Math.round(dt) || 1; // always show at least 1s to show timer running
73
74 return `${numSeconds}s`;
75 }
76
77 return publishTimeRelativeShort(value, now);
78};
79
80export enum TimeFormatType {
81 Post = 'post',

Callers 1

formatDateFunction · 0.85

Calls 1

publishTimeRelativeShortFunction · 0.85

Tested by

no test coverage detected