Spec the date math behind a range picker
Your task
Your TypeScript dashboard has a date range picker, with choices like "Mar 8 to Mar 14" and "Last 7 days". An agent will write the date logic behind it: turn a start and an end date into the list of days in the range, and work out the presets. The current code gets a day wrong for some users, depending on where the server and the user are.
Write the spec you would hand the agent.
What you know:
- dates reach the API as strings like
2026-03-08, and each user has a time zone such asAmerica/Los_Angeles - the backend servers run in UTC, and the frontend runs in users' browsers
- a range includes both ends and may span at most 366 days
- the team allows the Temporal polyfill,
@js-temporal/polyfill
Then, in a few sentences: what does "give me the days between two dates" get wrong?