From 8d4e11b912e44a7ad135aa7695ab3a10d9d3a26e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 13 Feb 2022 22:21:44 +0100 Subject: Remove parse-time from (datetime timespec). --- module/datetime/timespec.scm | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'module/datetime') diff --git a/module/datetime/timespec.scm b/module/datetime/timespec.scm index 712ff327..d3a84671 100644 --- a/module/datetime/timespec.scm +++ b/module/datetime/timespec.scm @@ -64,15 +64,6 @@ specs)) -(define (parse-time string) - (apply (lambda* (hour optional: (minute "0") (second "0")) - (time hour: (string->number hour) - minute: (string->number minute) - ;; discard sub-seconds - second: (string->number (car (string-split second #\.))))) - (string-split string #\:))) - - (define*-public (parse-time-spec string optional: (suffixes '(#\s #\w #\u #\g #\z))) (let* ((type string @@ -81,11 +72,12 @@ (values (string-ref string idx) (substring string 0 idx)))] [else (values #\w string)]))) + ;; Note that string->time allows a longer format than the input (cond [(string=? "-" string) (make-timespec (time) '+ type)] [(string-prefix? "-" string) - (make-timespec (parse-time (string-drop string 1)) + (make-timespec (string->time (string-drop string 1) "~H:~M:~S") '- type)] [else - (make-timespec (parse-time string) + (make-timespec (string->time string "~H:~M:~S") '+ type)]))) -- cgit v1.2.3