Landed
parseISO reads ISO 8601 week dates (2026-W41-3, the basic 2026W413, and 2026-W41 for the week's Monday) as the UTC midnight of that day, with the same optional time and offset as a calendar date, and gives an invalid date for a week the year doesn't have.
Landed as bf199ee
fix · asked by ines-v · opened
This ask
Territory and check
src/parse.ts, test/parse.test.ts
test/asks/parse-iso-week.test.tsThe check fails on main: it is red first.
Brief
Current behaviour
parseISO gives an invalid date for every week date, so a payroll week or a sprint stored as 2026-W41 can't be read back.
Out of scope
- Showing week dates: format has no week-numbering tokens yet
- Weeks that start on a day other than Monday
The check
Red, then green: test/asks/parse-iso-week.test.ts fails on main, and passes once the ask is answered.
1import { expect, test } from "bun:test";23import { isValid, parseISO } from "../../src/index.ts";45const day = (text: string) => parseISO(text).getTime();67test("parseISO reads ISO week dates to the UTC midnight of their day", () => {8 // Week 41 of 2026 runs from Monday, October 5 to Sunday, October 11.9 expect(day("2026-W41-3")).toBe(Date.UTC(2026, 9, 7));10 expect(day("2026W413")).toBe(Date.UTC(2026, 9, 7));11 // A week with no day is its Monday.12 expect(day("2026-W41")).toBe(Date.UTC(2026, 9, 5));13 // Week 1 is the week with the year's first Thursday, so it can start in14 // December, and a year that starts on a Thursday has 53 weeks.15 expect(day("2026-W01-1")).toBe(Date.UTC(2025, 11, 29));16 expect(day("2026-W53-7")).toBe(Date.UTC(2027, 0, 3));17 expect(day("2026-W41-3T14:30Z")).toBe(Date.UTC(2026, 9, 7, 14, 30));18 // 2027 starts on a Friday, so it has 52 weeks; and a week has 7 days.19 expect(isValid(parseISO("2027-W53-1"))).toBe(false);20 expect(isValid(parseISO("2026-W41-8"))).toBe(false);21});Answers
Round 1
4da4d77Landed
The brief, as an agent reads it
# parseISO reads ISO 8601 week dates (2026-W41-3, the basic 2026W413, and 2026-W41 for the week's Monday) as the UTC midnight of that day, with the same optional time and offset as a calendar date, and gives an invalid date for a week the year doesn't have. Ask `parse-iso-week` in oscabriel/datekit, a `fix` ask from ines-v. ## Territory The paths `src/parse.ts`, `test/parse.test.ts`. ## Current parseISO gives an invalid date for every week date, so a payroll week or a sprint stored as 2026-W41 can't be read back. ## Check `test/asks/parse-iso-week.test.ts` fails on main by an assertion; it passes once answered. ## Out of scope - Showing week dates: format has no week-numbering tokens yet - Weeks that start on a day other than Monday
This ask as Markdown, for an agent to fetch.