(import test rfc3339 (chicken time posix)) (test-begin "rfc3339->seconds") (test "1970-01-01T00:00:00-00:00" 0.0 (rfc3339->seconds (rfc3339 "1970-01-01T00:00:00-00:00"))) (test "1969-12-31T20:40:00-03:20" 0.0 (rfc3339->seconds (rfc3339 "1969-12-31T20:40:00-03:20"))) (test "1970-01-01T03:01:00+03:00" 60.0 (rfc3339->seconds (rfc3339 "1970-01-01T03:01:00+03:00"))) (test "2000-02-28T23:00:00-01:00" 951782400.0 (rfc3339->seconds (rfc3339 "2000-02-28T23:00:00-01:00"))) (test-end) (test-begin "seconds->rfc3339") (test "1970-01-01T00:00:00Z" "1970-01-01T00:00:00Z" (rfc3339->string (seconds->rfc3339 0))) (test "2000-02-29T00:00:00Z" "2000-02-29T00:00:00Z" (rfc3339->string (seconds->rfc3339 951782400.0))) (test-end) (test-begin "round-trip") (let ((str "1969-12-31T20:40:00+03:21")) (test str str (rfc3339->string (rfc3339 str)))) (test-end) (test-begin "normalization") (test "2000-02-28T23:00:00-01:00 utc-time->rfc3339" "2000-02-29T00:00:00Z" (rfc3339->string (time->rfc3339 (seconds->utc-time (rfc3339->seconds (rfc3339 "2000-02-28T23:00:00-01:00")))))) (test "2000-02-28T23:00:00-01:00 time->rfc3339" "2000-02-29T00:00:00Z" (rfc3339->string (utc-time->rfc3339 (seconds->utc-time (rfc3339->seconds (rfc3339 "2000-02-28T23:00:00-01:00")))))) (test-end) (test-exit)