Functional Weave
Code in Rust

dates.add-days@1.0.0

vectors.json

3,217 bytes · view raw

[
  { "name": "one day forward mid-month", "args": ["2026-09-16", 1], "expect": "2026-09-17" },
  { "name": "zero days is the same date back", "args": ["2026-09-16", 0], "expect": "2026-09-16" },
  { "name": "2024 is a leap year so 28 February is followed by the 29th", "args": ["2024-02-28", 1], "expect": "2024-02-29" },
  { "name": "2026 is not a leap year so 28 February rolls into March", "args": ["2026-02-28", 1], "expect": "2026-03-01" },
  { "name": "1900 was a century year and not a leap year", "args": ["1900-02-28", 1], "expect": "1900-03-01" },
  { "name": "2000 was divisible by 400 and was a leap year", "args": ["2000-02-28", 1], "expect": "2000-02-29" },
  { "name": "2100 is a century year and will not be a leap year", "args": ["2100-02-28", 1], "expect": "2100-03-01" },
  { "name": "31 January rolls to 1 February, never to 3 March", "args": ["2026-01-31", 1], "expect": "2026-02-01" },
  { "name": "31 March rolls to 1 April", "args": ["2026-03-31", 1], "expect": "2026-04-01" },
  { "name": "year rollover", "args": ["2026-12-31", 1], "expect": "2027-01-01" },
  { "name": "year rollover into a leap year", "args": ["1999-12-31", 1], "expect": "2000-01-01" },
  { "name": "negative offset crosses back over new year", "args": ["2027-01-01", -1], "expect": "2026-12-31" },
  { "name": "negative offset lands on the leap day", "args": ["2024-03-01", -1], "expect": "2024-02-29" },
  { "name": "negative offset skips the leap day that does not exist", "args": ["1900-03-01", -1], "expect": "1900-02-28" },
  { "name": "365 days in a common year lands on the same date", "args": ["2025-03-01", 365], "expect": "2026-03-01" },
  { "name": "365 days across a leap day lands a day short", "args": ["2024-01-01", 365], "expect": "2024-12-31" },
  { "name": "a large negative offset", "args": ["2026-09-16", -1000], "expect": "2023-12-21" },
  { "name": "a large positive offset", "args": ["2026-09-16", 10000], "expect": "2054-02-01" },
  { "name": "dates before the 1970 epoch work the same way", "args": ["1969-12-31", 1], "expect": "1970-01-01" },
  { "name": "a slash-separated date is an error, not a guess", "args": ["16/09/2026", 1], "expectError": "is not an ISO date" },
  { "name": "an unpadded month is an error", "args": ["2026-9-16", 1], "expectError": "is not an ISO date" },
  { "name": "a date with a time attached is an error", "args": ["2026-09-16T00:00:00Z", 1], "expectError": "is not an ISO date" },
  { "name": "30 February is not a real date and is not silently rolled forward", "args": ["2026-02-30", 1], "expectError": "is not a real calendar date" },
  { "name": "29 February in a non-leap year is rejected", "args": ["2026-02-29", 1], "expectError": "is not a real calendar date" },
  { "name": "month 13 is rejected", "args": ["2026-13-01", 1], "expectError": "is not a real calendar date" },
  { "name": "31 April is rejected", "args": ["2026-04-31", 1], "expectError": "is not a real calendar date" },
  { "name": "a fractional day count is an error", "args": ["2026-09-16", 1.5], "expectError": "days must be an integer" },
  { "name": "running off the end of the supported range is an error", "args": ["9999-12-31", 1], "expectError": "outside the supported range" }
]