unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Nathan Borghese via "Bug reports for GUILE, GNU's Ubiquitous Extension Language" <bug-guile@gnu.org>
To: 56632@debbugs.gnu.org
Subject: bug#56632: [PATCH] srfi-19: fix 12AM in ~I and ~l
Date: Mon, 18 Jul 2022 00:04:18 -0400	[thread overview]
Message-ID: <87zgh7awuh.fsf@nborghese.com> (raw)

[-- 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


                 reply	other threads:[~2022-07-18  4:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zgh7awuh.fsf@nborghese.com \
    --to=bug-guile@gnu.org \
    --cc=56632@debbugs.gnu.org \
    --cc=nathan@nborghese.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).