( expiresAt?: string | null, now: number = Date.now(), )
| 28 | |
| 29 | // "ends in 45m", or nothing while the room has hours ahead of it. |
| 30 | export const formatEndsIn = ( |
| 31 | expiresAt?: string | null, |
| 32 | now: number = Date.now(), |
| 33 | ): string | undefined => { |
| 34 | if (!expiresAt) { |
| 35 | return undefined; |
| 36 | } |
| 37 | const left = new Date(expiresAt).getTime() - now; |
| 38 | if (left > LIVE_CHAT_ENDS_SOON_MS) { |
| 39 | return undefined; |
| 40 | } |
| 41 | |
| 42 | return `ends in ${formatTimeLeft(expiresAt, now)}`; |
| 43 | }; |
no test coverage detected