diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-06-13 00:55:15 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-06-13 01:06:04 +0200 |
commit | 52378d6fbc0387c8315fed0d702b0919e63a8279 (patch) | |
tree | 0798055bca743582a0ac3ade526bb376bafa80cb /module | |
parent | Move recurrence output test to tests/. (diff) | |
download | calp-52378d6fbc0387c8315fed0d702b0919e63a8279.tar.gz calp-52378d6fbc0387c8315fed0d702b0919e63a8279.tar.xz |
Date, time & datetime now display themself in read-able forms.
Diffstat (limited to 'module')
-rw-r--r-- | module/datetime.scm | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/module/datetime.scm b/module/datetime.scm index 957303b7..8591f6f9 100644 --- a/module/datetime.scm +++ b/module/datetime.scm @@ -45,7 +45,7 @@ (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" + (format p "#~4'0d-~2'0d-~2'0d" (year r) (month r) (day r))))) (define*-public (date key: (year 0) (month 0) (day 0)) @@ -66,7 +66,7 @@ (not (integer? (second r)))) (format p "BAD~s:~s:~s" (hour r) (minute r) (second r)) - (format p "~2'0d:~2'0d:~2'0d" + (format p "#~2'0d:~2'0d:~2'0d" (hour r) (minute r) (second r))))) (define*-public (time key: (hour 0) (minute 0) (second 0)) @@ -82,6 +82,15 @@ (tz tz) ; #f, "UTC", "Europe/Stockholm", ... ) +(set-record-type-printer! + <datetime> + (lambda (r p) + (write `(datetime date: ,(get-date r) + time: ,(get-time% r) + ,@(awhen (tz r) + `(tz: ,it))) + p))) + (export get-date) (define-public (get-timezone datetime) (tz datetime)) |