Functional Weave
Code in TypeScript

time.minutes-between@1.0.0

vectors.json

2,035 bytes · view raw

[
  { "name": "a day shift on one date", "args": ["2026-09-22", "09:00", "2026-09-22", "17:30"], "expect": 510 },
  { "name": "a night shift across midnight is 480, not -960", "args": ["2026-09-22", "22:00", "2026-09-23", "06:00"], "expect": 480 },
  { "name": "the same instant is zero", "args": ["2026-09-22", "12:00", "2026-09-22", "12:00"], "expect": 0 },
  { "name": "an end before the start is negative", "args": ["2026-09-22", "12:30", "2026-09-22", "12:00"], "expect": -30 },
  { "name": "a whole day of minutes", "args": ["2026-09-22", "00:00", "2026-09-22", "23:59"], "expect": 1439 },
  { "name": "a shift longer than 24 hours", "args": ["2026-09-22", "08:00", "2026-09-23", "20:00"], "expect": 2160 },
  { "name": "across a year end", "args": ["2026-12-31", "23:45", "2027-01-01", "00:15"], "expect": 30 },
  { "name": "across 29 February", "args": ["2024-02-28", "12:00", "2024-03-01", "12:00"], "expect": 2880 },
  { "name": "across the UK clocks going forward: wall-clock 180, though 120 real minutes passed", "args": ["2026-03-29", "00:30", "2026-03-29", "03:30"], "expect": 180 },
  { "name": "across the UK clocks going back: wall-clock 180, though 240 real minutes passed", "args": ["2026-10-25", "00:30", "2026-10-25", "03:30"], "expect": 180 },
  { "name": "24:00 is not a time of day; use 00:00 on the next date", "args": ["2026-09-22", "20:00", "2026-09-22", "24:00"], "expectError": "\"24:00\" is not a time of day" },
  { "name": "an unpadded hour is rejected", "args": ["2026-09-22", "9:00", "2026-09-22", "17:00"], "expectError": "\"9:00\" is not a time of day" },
  { "name": "minute 60 is rejected", "args": ["2026-09-22", "12:60", "2026-09-22", "17:00"], "expectError": "\"12:60\" is not a time of day" },
  { "name": "a dotted time is rejected", "args": ["2026-09-22", "12.30", "2026-09-22", "17:00"], "expectError": "\"12.30\" is not a time of day" },
  { "name": "an impossible date is rejected", "args": ["2026-02-30", "12:00", "2026-03-01", "12:00"], "expectError": "is not a real calendar date" }
]