Functional Weave
Code in TypeScript

dates.days-between@1.0.0

vectors.json

1,707 bytes · view raw

[
  { "name": "the same date twice is zero days", "args": ["2026-09-22", "2026-09-22"], "expect": 0 },
  { "name": "the next day is one", "args": ["2026-09-22", "2026-09-23"], "expect": 1 },
  { "name": "1 to 31 January is 30, not 31: the difference, not an inclusive count", "args": ["2026-01-01", "2026-01-31"], "expect": 30 },
  { "name": "an end before the start is negative, not zero", "args": ["2026-09-23", "2026-09-22"], "expect": -1 },
  { "name": "across the end of February in a leap year", "args": ["2024-02-28", "2024-03-01"], "expect": 2 },
  { "name": "across the end of February in an ordinary year", "args": ["2026-02-28", "2026-03-01"], "expect": 1 },
  { "name": "across the UK clocks going forward is still one calendar day", "args": ["2026-03-29", "2026-03-30"], "expect": 1 },
  { "name": "a whole leap year is 366 days", "args": ["2024-01-01", "2025-01-01"], "expect": 366 },
  { "name": "a whole ordinary year is 365 days", "args": ["2025-01-01", "2026-01-01"], "expect": 365 },
  { "name": "1900 had no 29 February, so its year is 365 days", "args": ["1900-01-01", "1901-01-01"], "expect": 365 },
  { "name": "across the 1970 epoch", "args": ["1969-12-31", "1970-01-02"], "expect": 2 },
  { "name": "the full supported range", "args": ["0001-01-01", "9999-12-31"], "expect": 3652058 },
  { "name": "the full supported range, backwards", "args": ["9999-12-31", "0001-01-01"], "expect": -3652058 },
  { "name": "an impossible start date is an error, not 2 March", "args": ["2026-02-30", "2026-03-05"], "expectError": "is not a real calendar date" },
  { "name": "a UK-style date is an error, not a guess", "args": ["2026-01-01", "31/01/2026"], "expectError": "is not an ISO date" }
]