aboutsummaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-10-22 14:52:08 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-10-22 14:52:08 +0200
commit1e8171b95e146b18c2c173445bd34dc3cacee3af (patch)
tree2aae1a3faecbfd685ad1d7aea5f349a7c3dd0184 /module
parentAdd tests for sxml namespaced + fix 'root-element'. (diff)
downloadcalp-1e8171b95e146b18c2c173445bd34dc3cacee3af.tar.gz
calp-1e8171b95e146b18c2c173445bd34dc3cacee3af.tar.xz
Test work.
Diffstat (limited to 'module')
-rw-r--r--module/datetime.scm18
1 files changed, 14 insertions, 4 deletions
diff --git a/module/datetime.scm b/module/datetime.scm
index d54ba403..9bb536e3 100644
--- a/module/datetime.scm
+++ b/module/datetime.scm
@@ -737,12 +737,16 @@ Returns -1 on failure"
(loop* str fmt dt ampm))
(cond [(and (null? str) (null? fmt))
- (ampm dt)]
+ (if return-trailing
+ (values (ampm dt) '())
+ (ampm dt))]
[(null? str)
;; TODO it would be preferable to error out here. However, that fails for
;; optional specifiers (e.g. ~Z).
;; Also see the disabled test in "Premature end of string to parse"
- (ampm dt)
+ (if return-trailing
+ (values (ampm dt) '())
+ (ampm dt))
#; (err "Premature end of string, trailing fmt: ~s" fmt)]
[(null? fmt)
(if return-trailing
@@ -842,11 +846,17 @@ Returns -1 on failure"
(define* (string->time str optional: (fmt "~H:~M:~S") (locale %global-locale)
key: return-trailing)
- (datetime-time (string->datetime str fmt locale return-trailing: return-trailing)))
+ (call-with-values
+ (lambda () (string->datetime str fmt locale return-trailing: return-trailing))
+ (case-lambda ((dt) (datetime-time dt))
+ ((dt rem) (values (datetime-time dt) rem)))))
(define* (string->date str optional: (fmt "~Y-~m-~d") (locale %global-locale)
key: return-trailing)
- (datetime-date (string->datetime str fmt locale return-trailing: return-trailing)))
+ (call-with-values
+ (lambda () (string->datetime str fmt locale return-trailing: return-trailing))
+ (case-lambda ((dt) (datetime-date dt))
+ ((dt rem) (values (datetime-time dt) rem)))))
;; Parse @var{string} as either a date, time, or date-time.
;; String MUST be on iso-8601 format.