(define-module (datetime) :export (date? year month day hour minute second time? datetime?) ;; To resolve colision with cadr-second from srfi-1 :replace (second) :use-module (srfi srfi-1) :use-module (srfi srfi-9) :use-module (srfi srfi-9 gnu) :use-module (ice-9 match) :use-module (util) ) (define-many define-public (jan january ) 1 (feb february ) 2 (mar mars ) 3 (apr april ) 4 (may ) 5 (jun june ) 6 (jul july ) 7 (aug august ) 8 (sep september ) 9 (oct october ) 10 (nov november ) 11 (dec december ) 12 ) ;;; RECORD TYPES ;;; DATE (define-immutable-record-type (make-date year month day) date? (year year) (month month) (day day)) (set-record-type-printer! (lambda (r p) (if (or (not (integer? (year r))) (not (integer? (month r))) (not (integer? (day r)))) (format p "BAD~s-~s-~s" (year r) (month r) (day r)) (format p "~4'0d-~2'0d-~2'0d" (year r) (month r) (day r))))) (define*-public (date key: (year 0) (month 0) (day 0)) (make-date year month day)) ;;; TIME (define-immutable-record-type