Fix 12AM showing up as 0.
>From e9e084a8047ca9d189d8d751173196d906a1758f Mon Sep 17 00:00:00 2001
From: Nathan Borghese <[email protected]>
Date: Mon, 18 Jul 2022 00:01:08 -0400
Subject: [PATCH] srfi-19: fix ~I and ~l
* module/srfi/srfi-19.scm (directives): fix 12AM in ~I and ~l
---
module/srfi/srfi-19.scm | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/module/srfi/srfi-19.scm b/module/srfi/srfi-19.scm
index 948a34eef..c14672e9e 100644
--- a/module/srfi/srfi-19.scm
+++ b/module/srfi/srfi-19.scm
@@ -983,13 +983,9 @@
port)))
(cons #\I (lambda (date pad-with port)
(let ((hr (date-hour date)))
- (if (> hr 12)
- (display (padding (- hr 12)
- pad-with 2)
- port)
- (display (padding hr
- pad-with 2)
- port)))))
+ (display (padding (1+ (modulo (+ 11 (date-hour date)) 12))
+ pad-with 2)
+ port))))
(cons #\j (lambda (date pad-with port)
(display (padding (date-year-day date)
pad-with 3)
@@ -999,10 +995,9 @@
#\Space 2)
port)))
(cons #\l (lambda (date pad-with port)
- (let ((hr (if (> (date-hour date) 12)
- (- (date-hour date) 12) (date-hour date))))
- (display (padding hr #\Space 2)
- port))))
+ (display (padding (1+ (modulo (+ 11 (date-hour date)) 12))
+ #\Space 2)
+ port)))
(cons #\m (lambda (date pad-with port)
(display (padding (date-month date)
pad-with 2)
--
2.36.1