emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Kyle Meyer
Subject: [PATCH] org-test: Fix zone-dependent miscalculation of days of week
Date: Sat, 01 Jun 2024 17:43:11 -0400

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 via email to

[Prev in Thread] Current Thread [Next in Thread]