unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#56632: [PATCH] srfi-19: fix 12AM in ~I and ~l
@ 2022-07-18  4:04 Nathan Borghese via Bug reports for GUILE, GNU's Ubiquitous Extension Language
  0 siblings, 0 replies; only message in thread
From: Nathan Borghese via Bug reports for GUILE, GNU's Ubiquitous Extension Language @ 2022-07-18  4:04 UTC (permalink / raw)
  To: 56632

[-- Attachment #1: Type: text/plain, Size: 26 bytes --]

Fix 12AM showing up as 0.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 1934 bytes --]

From e9e084a8047ca9d189d8d751173196d906a1758f Mon Sep 17 00:00:00 2001
From: Nathan Borghese <nathan@nborghese.com>
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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-18  4:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-18  4:04 bug#56632: [PATCH] srfi-19: fix 12AM in ~I and ~l Nathan Borghese via Bug reports for GUILE, GNU's Ubiquitous Extension Language

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).