(now: Date = new Date())
| 16 | |
| 17 | /** This ISO week's Monday as YYYY-MM-DD in UTC, the way the API keys picks. */ |
| 18 | export const getCurrentWeekStart = (now: Date = new Date()): string => { |
| 19 | const today = Date.UTC( |
| 20 | now.getUTCFullYear(), |
| 21 | now.getUTCMonth(), |
| 22 | now.getUTCDate(), |
| 23 | ); |
| 24 | const daysSinceMonday = (new Date(today).getUTCDay() + 6) % 7; |
| 25 | |
| 26 | return new Date(today - daysSinceMonday * DAY_MS).toISOString().slice(0, 10); |
| 27 | }; |
| 28 | |
| 29 | /** |
| 30 | * Distinct posts of the week below which there is nothing worth nudging |
no outgoing calls