aboutsummaryrefslogtreecommitdiff
path: root/module/datetime
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-03-23 00:34:28 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2020-03-23 00:36:21 +0100
commitae47899079a448b2d71101d4b21c8e9409d82e34 (patch)
tree73fa1ec4d618d2a66650fee59b1e377cd7b3e40a /module/datetime
parentRemove unused datetime->decimal-hour. (diff)
downloadcalp-ae47899079a448b2d71101d4b21c8e9409d82e34.tar.gz
calp-ae47899079a448b2d71101d4b21c8e9409d82e34.tar.xz
Remove deprecated get-time.
Diffstat (limited to 'module/datetime')
-rw-r--r--module/datetime/util.scm39
1 files changed, 36 insertions, 3 deletions
diff --git a/module/datetime/util.scm b/module/datetime/util.scm
index ff75e86d..d5558aa2 100644
--- a/module/datetime/util.scm
+++ b/module/datetime/util.scm
@@ -150,7 +150,29 @@
#f
(string->list fmt)))))
-(define*-public (time->string time optional: (fmt "~H:~M:~S") key: allow-unknown?)
+;; (define*-public (time->string time optional: (fmt "~H:~M:~S") key: allow-unknown?)
+;; (with-output-to-string
+;; (lambda ()
+;; (fold (lambda (token state)
+;; (case state
+;; ((#\~)
+;; (case token
+;; ((#\~) (display "~"))
+;; ((#\H) (format #t "~2'0d" (hour time)))
+;; ((#\M) (format #t "~2'0d" (minute time)))
+;; ((#\S) (format #t "~2'0d" (second time)))
+;; ;; ((#\z) (when (utc? time) (display "Z")))
+;; (else (unless allow-unknown?
+;; (error 'time->string "Invalid format token ~a" token))))
+;; #f)
+;; (else (unless (char=? #\~ token) (display token)) token)))
+;; #f
+;; (string->list fmt)))))
+
+(define*-public (datetime->string datetime optional: (fmt "~Y-~m-~dT~H:~M:~S") key: allow-unknown?)
+ (define dt (get-datetime datetime))
+ (define date (get-date dt))
+ (define time ((@ (datetime) get-time%) dt))
(with-output-to-string
(lambda ()
(fold (lambda (token state)
@@ -161,9 +183,21 @@
((#\H) (format #t "~2'0d" (hour time)))
((#\M) (format #t "~2'0d" (minute time)))
((#\S) (format #t "~2'0d" (second time)))
+ ;; TODO
;; ((#\z) (when (utc? time) (display "Z")))
+ ((#\Y) (format #t "~4'0d" (year date)))
+ ((#\m) (format #t "~2'0d" (month date)))
+ ((#\d) (format #t "~2'0d" (day date)))
+ ;; Should be same as ~_d
+ ((#\e) (format #t "~2' d" (day date)))
+ ((#\1) (format #t "~4'0d-~2'0d-~2'0d"
+ (year date) (month date) (day date)))
+ ((#\a) (display (week-day-name (week-day date))))
+ ;; abriviated locale month name
+ ;; TODO locale
+ ((#\b) (display (month-name (month date))))
(else (unless allow-unknown?
- (error 'time->string "Invalid format token ~a" token))))
+ (error 'datetime->string "Invalid format token ~a" token))))
#f)
(else (unless (char=? #\~ token) (display token)) token)))
#f
@@ -171,7 +205,6 @@
-
;; @verbatim
;; A B C D E ¬F
;; |s1| : |s2| : |s1| : |s2| : : |s1|