From b12af06536d9d5b2225a02ef6060ecc65c9f6aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 13 Feb 2022 22:11:38 +0100 Subject: Datetime rewrote parse-month. --- module/datetime.scm | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'module/datetime.scm') 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") -- cgit v1.2.3