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

Function publishTimeLiveTimer

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

Source from the content-addressed store, hash-verified

75): string => format(new Date(value), "d MMMM yyyy 'at' HH:mm");
76
77export const publishTimeLiveTimer: typeof publishTimeRelativeShort = (
78 value,
79 now = new Date(),
80) => {
81 const date = new Date(value);
82
83 const dt = (now.getTime() - date.getTime()) / 1000;
84
85 if (dt <= oneMinute) {
86 const numSeconds = Math.round(dt) || 1; // always show at least 1s to show timer running
87
88 return `${numSeconds}s`;
89 }
90
91 return publishTimeRelativeShort(value, now);
92};
93
94export enum TimeFormatType {
95 Post = 'post',

Callers 1

formatDateFunction · 0.85

Calls 1

publishTimeRelativeShortFunction · 0.85

Tested by

no test coverage detected