emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: emacs-orgmode@gnu.org
Cc: ruijie@netyu.xyz, yantar92@posteo.net
Subject: [PATCH] org-test: Fix zone-dependent miscalculation of days of week
Date: Sat, 01 Jun 2024 17:43:11 -0400	[thread overview]
Message-ID: <87le3o5ogg.fsf@kyleam.com> (raw)

Hello,

Three clock tests are failing on my end:

   FAILED  test-org-clock/clock-drawer-dwim
   (... :explanation
    (array-elt 35 (different-atoms (87 "#x57" "?W") (84 "#x54" "?T"))))

   FAILED  test-org-clock/org-clock-timestamps-change
   (... :explanation
    (array-elt 20 (different-atoms (97 "#x61" "?a") (117 "#x75" "?u"))))

   FAILED  test-org-clok/org-clock-update-time-maybe
   (... :explanation
    (array-elt 19 (different-atoms (70 "#x46" "?F") (83 "#x53" "?S"))))

Those stem from org-test-day-of-weeks-{abbrev,full} not having the
expected value.  Those variables are supposed to list Sunday through
Saturday in the machine's locale.  Here's what I see on my end:

  org-test-day-of-weeks-full’s value is
  ["Saturday" "Monday" "Monday" "Tuesday" "Wednesday" "Thursday"
   "Friday"]

The patch below fixes the issue on my end.  In addition to my usual
locale, I tested it with another one (de_BE.utf8), and all the tests
passed.

-- >8 --
Subject: [PATCH] org-test: Fix zone-dependent miscalculation of days of week

* testing/org-test.el (org-test-day-of-weeks-seconds): Specify seconds
for formatting with UTC as time zone.
(org-test-day-of-weeks-abbrev):
(org-test-day-of-weeks-full): Use UTC as time zone when formatting
input.

Avoid calling format-time-string with the local time zone because that
gives the wrong result in some cases.  For example, 2222222 is
supposed to produce the locale's name for "Tuesday" but, when the
local time zone is +0000, (format-time-string "%A" 2222222) returns
the locale's name for "Monday".
---
 testing/org-test.el | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/testing/org-test.el b/testing/org-test.el
index d9fe33284..643c5c766 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -549,26 +549,26 @@ (defmacro org-test-capture-warnings (&rest body)
      (nreverse messages)))
 
 (defconst org-test-day-of-weeks-seconds
-  [121223891                            ; Sun
-   30000000                             ; Mon
-   2222222                              ; Tue
-   500000                               ; Wed
-   1000                                 ; Thu
-   89173                                ; Fri
-   666666666]                           ; Sat
+  [302400                               ; Sun
+   388800                               ; Mon
+   475200                               ; Tue
+   561600                               ; Wed
+   648000                               ; Thu
+   734400                               ; Fri
+   820800]                              ; Sat
   "Epoch seconds for generating days of week strings.
 Starts at Sunday, ends at Saturday.")
 
 (defconst org-test-day-of-weeks-abbrev
   (apply #'vector
-         (seq-map (apply-partially #'format-time-string "%a")
+         (seq-map (lambda (s) (format-time-string "%a" s t))
                   org-test-day-of-weeks-seconds))
   "Vector of abbreviated names of days of week.
 See `org-test-day-of-weeks-seconds'.")
 
 (defconst org-test-day-of-weeks-full
   (apply #'vector
-         (seq-map (apply-partially #'format-time-string "%A")
+         (seq-map (lambda (s) (format-time-string "%A" s t))
                   org-test-day-of-weeks-seconds))
   "Vector of full names for days of week.
 See `org-test-day-of-weeks-seconds'.")

base-commit: 671ca44df04801514fd77faf06e7e0b3216188a6
-- 
2.41.0



             reply	other threads:[~2024-06-01 21:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-01 21:43 Kyle Meyer [this message]
2024-06-03 15:00 ` [PATCH] org-test: Fix zone-dependent miscalculation of days of week Ihor Radchenko
2024-06-04  1:45   ` Kyle Meyer
2024-06-04 13:04     ` Ihor Radchenko
  -- strict thread matches above, loose matches on Subject: below --
2024-06-04  1:08 Kyle Meyer

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.orgmode.org/

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

  git send-email \
    --in-reply-to=87le3o5ogg.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=ruijie@netyu.xyz \
    --cc=yantar92@posteo.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).