time.scm 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. ;;; R7RS compatibility libraries
  2. ;;; Copyright (C) 2019 Free Software Foundation, Inc.
  3. ;;;
  4. ;;; This library is free software: you can redistribute it and/or modify
  5. ;;; it under the terms of the GNU Lesser General Public License as
  6. ;;; published by the Free Software Foundation, either version 3 of the
  7. ;;; License, or (at your option) any later version.
  8. ;;;
  9. ;;; This library is distributed in the hope that it will be useful, but
  10. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. ;;; Lesser General Public License for more details.
  13. ;;;
  14. ;;; You should have received a copy of the GNU Lesser General Public
  15. ;;; License along with this program. If not, see
  16. ;;; <http://www.gnu.org/licenses/>.
  17. (define-module (scheme time)
  18. #:use-module (srfi srfi-19)
  19. #:export (current-jiffy current-second jiffies-per-second))
  20. (define (jiffies-per-second)
  21. internal-time-units-per-second)
  22. (define (current-jiffy)
  23. (get-internal-real-time))
  24. (define (current-second)
  25. (let ((t (current-time time-tai)))
  26. (+ (time-second t)
  27. (* 1e-9 (time-nanosecond t)))))