| 19 | |
| 20 | /** The picker's choice for a change that is already running. */ |
| 21 | export const getDurationFor = ( |
| 22 | expiresAt: string | null | undefined, |
| 23 | now = Date.now(), |
| 24 | ): FeedControlDuration | undefined => { |
| 25 | if (!expiresAt) { |
| 26 | return undefined; |
| 27 | } |
| 28 | return new Date(expiresAt).getTime() <= |
| 29 | now + durationDays[FeedControlDuration.ThreeDays] * dayMs |
| 30 | ? FeedControlDuration.ThreeDays |
| 31 | : FeedControlDuration.Week; |
| 32 | }; |
| 33 | |
| 34 | // The API sets the real one; this is for the change shown before it answers. |
| 35 | export const getExpiresAt = ( |