* [PATCH] org-test: Fix zone-dependent miscalculation of days of week
@ 2024-06-01 21:43 Kyle Meyer
2024-06-03 15:00 ` Ihor Radchenko
0 siblings, 1 reply; 5+ messages in thread
From: Kyle Meyer @ 2024-06-01 21:43 UTC (permalink / raw)
To: emacs-orgmode; +Cc: ruijie, yantar92
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] org-test: Fix zone-dependent miscalculation of days of week
2024-06-01 21:43 [PATCH] org-test: Fix zone-dependent miscalculation of days of week Kyle Meyer
@ 2024-06-03 15:00 ` Ihor Radchenko
2024-06-04 1:45 ` Kyle Meyer
0 siblings, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2024-06-03 15:00 UTC (permalink / raw)
To: Kyle Meyer; +Cc: emacs-orgmode
Kyle Meyer <kyle@kyleam.com> writes:
> Three clock tests are failing on my end:
>
> FAILED test-org-clock/clock-drawer-dwim
> FAILED test-org-clock/org-clock-timestamps-change
> FAILED test-org-clok/org-clock-update-time-maybe
>
> 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.
> ...
> (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
I suspect that the failures are because of your timezone.
If my guess is right, there will always be some timezone where a given
number seconds from epoch is a different day...
I am not sure how to address this problem.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] org-test: Fix zone-dependent miscalculation of days of week
2024-06-03 15:00 ` Ihor Radchenko
@ 2024-06-04 1:45 ` Kyle Meyer
2024-06-04 13:04 ` Ihor Radchenko
0 siblings, 1 reply; 5+ messages in thread
From: Kyle Meyer @ 2024-06-04 1:45 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
[ Sorry, I somehow managed to drop the References and In-Reply-to
headers from my previous reply. I'll include that message again here
along with some examples. ]
Ihor Radchenko writes:
> I suspect that the failures are because of your timezone.
Yes, that matches my conclusion too and was what I was trying to convey
in the commit message.
> If my guess is right, there will always be some timezone where a given
> number seconds from epoch is a different day...
> I am not sure how to address this problem.
How about my patch? Notice that format-time-string is invoked with ZONE
set to t so that TIME is always taken as UTC.
Examples
--------
;;; locale en_US.UTF-8
;; local time zone (Japan in this demo)
(format-time-string "%A %T %z" 259200) => "Sunday 09:00:00 +0900"
;; force UTC
(format-time-string "%A %T %z" 259200 t) => "Sunday 00:00:00 +0000"
;; locale de_BE.UTF-8
;; local time zone
(format-time-string "%A %T %z" 259200) => "Sonntag 09:00:00 +0900"
;; force UTC
(format-time-string "%A %T %z" 259200 t) => "Sonntag 00:00:00 +0000"
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] org-test: Fix zone-dependent miscalculation of days of week
@ 2024-06-04 1:08 Kyle Meyer
0 siblings, 0 replies; 5+ messages in thread
From: Kyle Meyer @ 2024-06-04 1:08 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
Ihor Radchenko writes:
> I suspect that the failures are because of your timezone.
Yes, that matches my conclusion too and was what I was trying to convey
in the commit message.
> If my guess is right, there will always be some timezone where a given
> number seconds from epoch is a different day...
> I am not sure how to address this problem.
How about my patch? Notice that format-time-string is invoked with ZONE
set to t so that TIME is always taken as UTC.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-06-04 13:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-01 21:43 [PATCH] org-test: Fix zone-dependent miscalculation of days of week Kyle Meyer
2024-06-03 15:00 ` 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
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).