( value, now = new Date(), )
| 75 | ): string => format(new Date(value), "d MMMM yyyy 'at' HH:mm"); |
| 76 | |
| 77 | export 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 | |
| 94 | export enum TimeFormatType { |
| 95 | Post = 'post', |
no test coverage detected