aboutsummaryrefslogtreecommitdiff
path: root/module/datetime.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-03-31 00:38:00 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-03-31 00:38:00 +0200
commit4889e9fc9d4756803c0eb7f700ecd32fcfa61404 (patch)
treea98ab11468a651e113687bf462f47abdafb243ba /module/datetime.scm
parentFixed minor errors in HTML output. (diff)
downloadcalp-4889e9fc9d4756803c0eb7f700ecd32fcfa61404.tar.gz
calp-4889e9fc9d4756803c0eb7f700ecd32fcfa61404.tar.xz
Rename parse-date to parse-ics-date, add parse-iso-date.
Diffstat (limited to 'module/datetime.scm')
-rw-r--r--module/datetime.scm18
1 files changed, 13 insertions, 5 deletions
diff --git a/module/datetime.scm b/module/datetime.scm
index 4fef907f..30fb6025 100644
--- a/module/datetime.scm
+++ b/module/datetime.scm
@@ -657,22 +657,22 @@
(define (s->n str from to)
(string->number (substring/read-only str from to)))
-(define-public (parse-date str)
+(define-public (parse-ics-date str)
(date year: (s->n str 0 4)
month: (s->n str 4 6)
day: (s->n str 6 8)))
-(define-public (parse-time str)
+(define-public (parse-ics-time str)
(time hour: (s->n str 0 2)
minute: (s->n str 2 4)
second: (s->n str 4 6)))
-(define*-public (parse-datetime str optional: tz)
+(define*-public (parse-ics-datetime str optional: tz)
(unless (string-any #\T str)
(throw 'parse-error "String ~a doesn't look like a valid datetime" str))
(let* (((datestr timestr) (string-split str #\T)))
- (datetime date: (parse-date datestr)
- time: (parse-time timestr)
+ (datetime date: (parse-ics-date datestr)
+ time: (parse-ics-time timestr)
tz: tz)))
@@ -691,6 +691,10 @@
(let* (((year month day) (map string->number (string-split str #\-))))
`(date year: ,year month: ,month day: ,day)))
+(define-public (parse-iso-date str)
+ (let* (((year month day) (map string->number (string-split str #\-))))
+ (date year: year month: month day: day)))
+
(define (parse-time% timestr)
(let* (((hour minute second) (string-split timestr #\:)))
(let ((hour (string->number hour))
@@ -698,6 +702,10 @@
(second (string->number second)))
`(time hour: ,hour minute: ,minute second: ,second))))
+(define-public (parse-iso-time str)
+ (let* (((hour minute second) (map string->number (string-split str #\:))))
+ (time hour: hour minute: minute second: second)))
+
(define (parse-datetime% str)
(let* (((date time) (string-split str #\T)))
(when (string= "Z" (string-take-right str 1))