diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-04-02 23:13:30 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-04-02 23:13:30 +0200 |
commit | 86ccf30525d820a03831f9fb934a3044cec41416 (patch) | |
tree | bae8c5438732706c4d6e20a19bcaa22e0e8a3991 /module/datetime/util.scm | |
parent | Made date->str use datetime->str. Reintroduce time->str. (diff) | |
download | calp-86ccf30525d820a03831f9fb934a3044cec41416.tar.gz calp-86ccf30525d820a03831f9fb934a3044cec41416.tar.xz |
week-day-name rethrow with better error.
Diffstat (limited to '')
-rw-r--r-- | module/datetime/util.scm | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/module/datetime/util.scm b/module/datetime/util.scm index 5ba06da4..3ae270bd 100644 --- a/module/datetime/util.scm +++ b/module/datetime/util.scm @@ -103,7 +103,10 @@ (define*-public (week-day-name week-day-number optional: truncate-to) ;; NOTE this allows days larger than 7 (sunday if counting from monday). - (let ((str (locale-day (modulo (1+ week-day-number) 7)))) + (let ((str (catch 'out-of-range + (lambda () (locale-day (1+ (modulo week-day-number 7)))) + (lambda (oor str num) (scm-error 'out-of-range 'week-day-name "~a == (~a % 7) + 1" + (list num week-day-number) (list week-day-number)))))) ;; I also know about the @var{locale-day-short} method, but I need ;; strings of length 2. (if truncate-to |