Functional Weave
Code in Python

time.unix-to-iso@1.0.0

vectors.json

1,735 bytes · view raw

[
  {"name": "the epoch", "args": [0], "expect": "1970-01-01T00:00:00Z"},
  {"name": "one second after the epoch", "args": [1], "expect": "1970-01-01T00:00:01Z"},
  {"name": "one second before the epoch is the previous day, which truncating division gets wrong", "args": [-1], "expect": "1969-12-31T23:59:59Z"},
  {"name": "the last second of the first day", "args": [86399], "expect": "1970-01-01T23:59:59Z"},
  {"name": "2000 was a leap year (divisible by 400)", "args": [951782400], "expect": "2000-02-29T00:00:00Z"},
  {"name": "2100 will not be a leap year: 1 March follows 28 February", "args": [4107542400], "expect": "2100-03-01T00:00:00Z"},
  {"name": "the famous 1234567890", "args": [1234567890], "expect": "2009-02-13T23:31:30Z"},
  {"name": "the exp of the RFC 7519 example token", "args": [1300819380], "expect": "2011-03-22T18:43:00Z"},
  {"name": "the last second a signed 32-bit time_t can hold", "args": [2147483647], "expect": "2038-01-19T03:14:07Z"},
  {"name": "one second past 2038, which int64 handles", "args": [2147483648], "expect": "2038-01-19T03:14:08Z"},
  {"name": "the last second of year 9999", "args": [253402300799], "expect": "9999-12-31T23:59:59Z"},
  {"name": "the first second of year 0001", "args": [-62135596800], "expect": "0001-01-01T00:00:00Z"},
  {"name": "one second past year 9999", "args": [253402300800], "expectError": "seconds must be from -62135596800 to 253402300799 (years 0001 to 9999), received 253402300800"},
  {"name": "milliseconds passed as seconds land far past year 9999", "args": [1790000000000], "expectError": "seconds must be from -62135596800 to 253402300799"},
  {"name": "a fractional second count", "args": [1.5], "expectError": "seconds must be a whole number"}
]