1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Fix typos, indentation and error reporting in SRFI-19.

* module/srfi/srfi-19.scm: Fix typos in comments, indentation, and pass
the correct 'caller' name to 'time-error' in several places.
This commit is contained in:
Mark H Weaver 2018-10-16 04:20:47 -04:00 committed by Andy Wingo
parent d61da427e1
commit a47a5e6828

View file

@ -311,7 +311,7 @@
;; (* (remainder current-ms 1000) 10000))))
;; -- we define it to be the same as TAI.
;; A different implemation of current-time-montonic
;; A different implemention of current-time-monotonic
;; will require rewriting all of the time-monotonic converters,
;; of course.
@ -323,7 +323,7 @@
(time-second tai))))
(define (current-time-thread)
(time-error 'current-time 'unsupported-clock-type 'time-thread))
(time-error 'current-time-thread 'unsupported-clock-type 'time-thread))
(define ns-per-guile-tick (/ 1000000000 internal-time-units-per-second))
@ -371,8 +371,13 @@
;; also presume it will be rare to check two times of different types.
(and (= (time-second t1) (time-second t2))
(= (time-nanosecond t1) (time-nanosecond t2))
;; XXX The SRFI-19 reference implementation raises an error in
;; case of unequal time types. Here we return #false.
(eq? (time-type t1) (time-type t2))))
;; XXX In the following comparison procedures, the SRFI-19 reference
;; implementation raises an error in case of unequal time types.
(define (time>? t1 t2)
(or (> (time-second t1) (time-second t2))
(and (= (time-second t1) (time-second t2))
@ -395,6 +400,9 @@
;; -- Time arithmetic
;; XXX In the following comparison procedures, the SRFI-19 reference
;; implementation raises an error in case of unequal time types.
(define (time-difference! time1 time2)
(let ((sec-diff (- (time-second time1) (time-second time2)))
(nsec-diff (- (time-nanosecond time1) (time-nanosecond time2))))
@ -409,7 +417,7 @@
(define (add-duration! t duration)
(if (not (eq? (time-type duration) time-duration))
(time-error 'add-duration 'not-duration duration)
(time-error 'add-duration! 'not-duration duration)
(let ((sec-plus (+ (time-second t) (time-second duration)))
(nsec-plus (+ (time-nanosecond t) (time-nanosecond duration))))
(set-time-second! t sec-plus)
@ -422,7 +430,7 @@
(define (subtract-duration! t duration)
(if (not (eq? (time-type duration) time-duration))
(time-error 'add-duration 'not-duration duration)
(time-error 'subtract-duration! 'not-duration duration)
(let ((sec-minus (- (time-second t) (time-second duration)))
(nsec-minus (- (time-nanosecond t) (time-nanosecond duration))))
(set-time-second! t sec-minus)
@ -600,7 +608,7 @@
(define (time-utc->date time . tz-offset)
(if (not (eq? (time-type time) time-utc))
(time-error 'time->date 'incompatible-time-types time))
(time-error 'time-utc->date 'incompatible-time-types time))
(let* ((offset (if (null? tz-offset)
(local-tz-offset time)
(car tz-offset)))
@ -630,7 +638,7 @@
(define (time-tai->date time . tz-offset)
(if (not (eq? (time-type time) time-tai))
(time-error 'time->date 'incompatible-time-types time))
(time-error 'time-tai->date 'incompatible-time-types time))
(let* ((offset (if (null? tz-offset)
(local-tz-offset (time-tai->time-utc time))
(car tz-offset)))
@ -663,7 +671,7 @@
;; this is the same as time-tai->date.
(define (time-monotonic->date time . tz-offset)
(if (not (eq? (time-type time) time-monotonic))
(time-error 'time->date 'incompatible-time-types time))
(time-error 'time-monotonic->date 'incompatible-time-types time))
(let* ((offset (if (null? tz-offset)
(local-tz-offset (time-monotonic->time-utc time))
(car tz-offset)))
@ -814,7 +822,7 @@
(define (time-utc->julian-day time)
(if (not (eq? (time-type time) time-utc))
(time-error 'time->date 'incompatible-time-types time))
(time-error 'time-utc->julian-day 'incompatible-time-types time))
(+ (/ (+ (time-second time) (/ (time-nanosecond time) nano))
sid)
tai-epoch-in-jd))
@ -825,7 +833,7 @@
(define (time-tai->julian-day time)
(if (not (eq? (time-type time) time-tai))
(time-error 'time->date 'incompatible-time-types time))
(time-error 'time-tai->julian-day 'incompatible-time-types time))
(+ (/ (+ (- (time-second time)
(leap-second-delta (time-second time)))
(/ (time-nanosecond time) nano))
@ -839,7 +847,7 @@
;; this is the same as time-tai->julian-day
(define (time-monotonic->julian-day time)
(if (not (eq? (time-type time) time-monotonic))
(time-error 'time->date 'incompatible-time-types time))
(time-error 'time-monotonic->julian-day 'incompatible-time-types time))
(+ (/ (+ (- (time-second time)
(leap-second-delta (time-second time)))
(/ (time-nanosecond time) nano))