srfi-19-objects.scm 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. (import (srfi srfi-19))
  2. (simple-format (current-output-port) "date: ~s\n" (current-date))
  3. (simple-format (current-output-port) "date: ~s\n" (make-date 0 0 0 10 13 3 2021 0))
  4. (simple-format (current-output-port) "time: ~s\n" (current-time time-utc))
  5. (define seconds 1)
  6. (define minutes (* 60 seconds))
  7. (define hours (* 60 minutes))
  8. ;; calculate time differences / durations
  9. (let ([now (current-time time-utc)])
  10. (let* ([now+1h
  11. (add-duration now (make-time time-duration 0 (* 1 hours)))]
  12. [now+2h30min
  13. (add-duration
  14. (add-duration now (make-time time-duration 0 (* 2 hours)))
  15. (make-time time-duration 0 (* 30 minutes)))]
  16. [time-diff+1h
  17. (time-difference now+1h now)]
  18. [time-diff+2h30min
  19. (time-difference now+2h30min now)])
  20. (simple-format (current-output-port) "duration: ~s\n" time-diff+1h)
  21. (simple-format (current-output-port) "duration in s: ~s\n" (time-second time-diff+1h))
  22. (simple-format (current-output-port) "duration: ~s\n" time-diff+2h30min)
  23. (simple-format (current-output-port) "duration in s: ~s\n" (time-second time-diff+2h30min))))
  24. ;; Compare dates
  25. (let* ([now (current-time time-utc)]
  26. [now+1h (add-duration now (make-time time-duration 0 (* 1 hours)))])
  27. (simple-format (current-output-port) "now <= now+1h: ~s\n" (time<=? now now+1h))
  28. (simple-format (current-output-port) "now < now+1h: ~s\n" (time<? now now+1h))
  29. (simple-format (current-output-port) "now = now+1h: ~s\n" (time=? now now+1h))
  30. (simple-format (current-output-port) "now >= now+1h: ~s\n" (time>=? now now+1h))
  31. (simple-format (current-output-port) "now > now+1h: ~s\n" (time>? now now+1h)))