aboutsummaryrefslogtreecommitdiff
path: root/module/datetime.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-02-13 22:11:38 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-02-13 22:11:38 +0100
commitb12af06536d9d5b2225a02ef6060ecc65c9f6aae (patch)
treee6d4c99305ee41a37efe1124966e93b3f7bab4e6 /module/datetime.scm
parentDatetime test parse-month. (diff)
downloadcalp-b12af06536d9d5b2225a02ef6060ecc65c9f6aae.tar.gz
calp-b12af06536d9d5b2225a02ef6060ecc65c9f6aae.tar.xz
Datetime rewrote parse-month.
Diffstat (limited to 'module/datetime.scm')
-rw-r--r--module/datetime.scm21
1 files changed, 11 insertions, 10 deletions
diff --git a/module/datetime.scm b/module/datetime.scm
index e8dc72f7..d0025316 100644
--- a/module/datetime.scm
+++ b/module/datetime.scm
@@ -661,18 +661,19 @@ Returns -1 on failure"
-(define* (parse-month str optional: (locale %global-locale))
+(define*-public (parse-month str optional: (locale %global-locale))
"Get month number from a (shortened) monthname.
Returns -1 on failure"
- (cond ((find (match-lambda ((_ name)
- (let ((len (min (string-length name)
- (string-length str))))
- (string-locale-ci=? (string-take str len)
- (string-take name len)
- locale))))
- (enumerate (map (lambda (n) (locale-month n locale)) (iota 12 1))))
- => (compose 1+ car))
- (else -1)))
+ (or
+ (find (lambda (n)
+ (define name (locale-month n locale))
+ (define len (min (string-length name)
+ (string-length str)))
+ (string-locale-ci=? (string-take str len)
+ (string-take name len)
+ locale))
+ (iota 12 1))
+ -1))
(define*-public (string->datetime str optional: (fmt "~Y-~m-~dT~H:~M:~S~Z")