bug#56632: [PATCH] srfi-19: fix 12AM in ~I and ~l

Nathan Borghese via "Bug reports for GUILE, GNU's Ubiquitous Extension Language" <[email protected]>
Newsgroups gmane.lisp.guile.bugs
Message-ID <[email protected]>
Fix 12AM showing up as 0.
0001-srfi-19-fix-I-and-l.patch (text/x-patch, 1.9 KB)
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.