Functional Weave
Code in Rust

time.iso-to-unix@1.0.0

vectors.json

2,573 bytes · view raw

[
  {"name": "the epoch", "args": ["1970-01-01T00:00:00Z"], "expect": 0},
  {"name": "the famous 1234567890", "args": ["2009-02-13T23:31:30Z"], "expect": 1234567890},
  {"name": "one second before the epoch", "args": ["1969-12-31T23:59:59Z"], "expect": -1},
  {"name": "the last second of a signed 32-bit time_t", "args": ["2038-01-19T03:14:07Z"], "expect": 2147483647},
  {"name": "British Summer Time: an hour ahead of UTC, so an hour is taken off", "args": ["2026-09-26T13:00:00+01:00"], "expect": 1790424000},
  {"name": "a negative half-hour offset is added back", "args": ["2026-09-26T06:30:00-05:30"], "expect": 1790424000},
  {"name": "a fraction is dropped, not rounded up to the next second", "args": ["2026-09-26T12:00:00.999Z"], "expect": 1790424000},
  {"name": "RFC 3339 allows a lowercase t and z", "args": ["2026-09-26t12:00:00z"], "expect": 1790424000},
  {"name": "-00:00 is UTC, on a leap day", "args": ["2000-02-29T12:00:00-00:00"], "expect": 951825600},
  {"name": "the first second of year 0001", "args": ["0001-01-01T00:00:00Z"], "expect": -62135596800},
  {"name": "a time with no zone is ambiguous", "args": ["2026-09-26T12:00:00"], "expectError": "is not an RFC 3339 timestamp such as 2026-09-26T12:00:00Z"},
  {"name": "a space instead of T", "args": ["2026-09-26 12:00:00Z"], "expectError": "is not an RFC 3339 timestamp such as 2026-09-26T12:00:00Z"},
  {"name": "hour 24", "args": ["2026-09-26T24:00:00Z"], "expectError": "is not an RFC 3339 timestamp such as 2026-09-26T12:00:00Z"},
  {"name": "a leap second has no Unix time", "args": ["2026-09-26T23:59:60Z"], "expectError": "is not an RFC 3339 timestamp such as 2026-09-26T12:00:00Z"},
  {"name": "a decimal point with no digits", "args": ["2026-09-26T12:00:00.Z"], "expectError": "is not an RFC 3339 timestamp such as 2026-09-26T12:00:00Z"},
  {"name": "no seconds", "args": ["2026-09-26T12:00Z"], "expectError": "is not an RFC 3339 timestamp such as 2026-09-26T12:00:00Z"},
  {"name": "an offset without its colon", "args": ["2026-09-26T12:00:00+0100"], "expectError": "is not an RFC 3339 timestamp such as 2026-09-26T12:00:00Z"},
  {"name": "a trailing newline", "args": ["2026-09-26T12:00:00Z\n"], "expectError": "is not an RFC 3339 timestamp such as 2026-09-26T12:00:00Z"},
  {"name": "Arabic-Indic digits in the year", "args": ["٢٠٢٦-09-26T12:00:00Z"], "expectError": "is not an RFC 3339 timestamp such as 2026-09-26T12:00:00Z"},
  {"name": "a well-formed timestamp on a day that does not exist", "args": ["2026-02-30T00:00:00Z"], "expectError": "is not a real calendar date"}
]