( value, now = new Date(), )
| 61 | ): string => format(new Date(value), "d MMMM yyyy 'at' HH:mm"); |
| 62 | |
| 63 | export 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 | |
| 80 | export enum TimeFormatType { |
| 81 | Post = 'post', |
no test coverage detected