| 234 | * Compute the immediately-preceding period given a (start, end) range. |
| 235 | */ |
| 236 | export function previousPeriod(startDate: string, endDate: string) { |
| 237 | const start = new Date(startDate).getTime(); |
| 238 | const end = new Date(endDate).getTime(); |
| 239 | const span = end - start; |
| 240 | return { |
| 241 | startDate: new Date(start - span - 86_400_000).toISOString().slice(0, 10), |
| 242 | endDate: new Date(start - 86_400_000).toISOString().slice(0, 10), |
| 243 | }; |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Build a clickable dashboard URL for a tool result. |