18 lines
669 B
Scheme
18 lines
669 B
Scheme
;;; unit/time.scm
|
|
|
|
(define-module (unit time)
|
|
#:use-module (ice-9 match)
|
|
#:export (parse-unit/time))
|
|
|
|
|
|
(define (parse-unit/time unit)
|
|
;; Parse the units of time (second, minute, hour, etc.)
|
|
(match unit
|
|
((or 's 'sec 'second 'seconds) 1)
|
|
((or 'min 'minute 'minutes) (* 60 (parse-unit/time 'second)))
|
|
((or 'h 'hr 'hour 'hours) (* 60 (parse-unit/time 'minute)))
|
|
((or 'd 'day 'days) (* 24 (parse-unit/time 'hour)))
|
|
((or 'w 'week 'weeks) (* 7 (parse-unit/time 'day)))
|
|
((or 'mo 'month 'months) (* 30 (parse-unit/time 'day))) ; uhh
|
|
((or 'y 'yr 'year 'years) (* 365 (parse-unit/time 'day))) ; (trust)
|
|
(else (error "Invalid unit" unit))))
|