diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-02-13 22:11:38 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-02-13 22:11:38 +0100 |
commit | b12af06536d9d5b2225a02ef6060ecc65c9f6aae (patch) | |
tree | e6d4c99305ee41a37efe1124966e93b3f7bab4e6 /module/datetime.scm | |
parent | Datetime test parse-month. (diff) | |
download | calp-b12af06536d9d5b2225a02ef6060ecc65c9f6aae.tar.gz calp-b12af06536d9d5b2225a02ef6060ecc65c9f6aae.tar.xz |
Datetime rewrote parse-month.
Diffstat (limited to 'module/datetime.scm')
-rw-r--r-- | module/datetime.scm | 21 |
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") |