branch: externals/org
commit 9730f408c20d2cccdcd72ee1c508859d2b64a3ec
Author: Ihor Radchenko <[email protected]>
Commit: Ihor Radchenko <[email protected]>
testing/org-test.el: New helper function `org-test-get-day-name'
* testing/org-test.el (org-test-get-day-name): New function to convert
English day name to current locale.
* testing/lisp/test-org-clock.el
(test-org-clock/org-clock-timestamps-change):
(test-org-clock/clock-drawer-dwim): Use the new function instead of
direct `aref'.
---
testing/lisp/test-org-clock.el | 6 +++---
testing/org-test.el | 17 +++++++++++++++++
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el
index 19d0c68ecf..fe51b12b6b 100644
--- a/testing/lisp/test-org-clock.el
+++ b/testing/lisp/test-org-clock.el
@@ -91,8 +91,8 @@ the buffer."
(ert-deftest test-org-clock/org-clock-timestamps-change ()
"Test `org-clock-timestamps-change' specifications."
- (let ((sun (aref org-test-day-of-weeks-abbrev 0))
- (mon (aref org-test-day-of-weeks-abbrev 1)))
+ (let ((sun (org-test-get-day-name "Sun"))
+ (mon (org-test-get-day-name "Mon")))
(should
(equal
(format "CLOCK: [2023-02-19 %s 21:30]--[2023-02-19 %s 23:35] => 2:05"
@@ -318,7 +318,7 @@ the buffer."
(ert-deftest test-org-clock/clock-drawer-dwim ()
"Test DWIM update of days for clocks in logbook drawers."
- (let ((thu (aref org-test-day-of-weeks-abbrev 4)))
+ (let ((thu (org-test-get-day-name "Thu")))
(should (equal (format "* Foo
:LOGBOOK:
CLOCK: [2022-11-03 %s 06:00]--[2022-11-03 %s 06:01] => 0:01
diff --git a/testing/org-test.el b/testing/org-test.el
index ced281e235..47687b9f7a 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -572,6 +572,23 @@ See `org-test-day-of-weeks-seconds'.")
"Vector of full names for days of week.
See `org-test-day-of-weeks-seconds'.")
+(defun org-test-get-day-name (day &optional full)
+ "Return string containing locale-specific DAY abbrev.
+DAY Should be Mon, Tue, ...
+When FULL is non-nil, return the full name like Monday, Tuesday, ..."
+ (aref
+ (if full org-test-day-of-weeks-full
+ org-test-day-of-weeks-abbrev)
+ (pcase day
+ ((or "Sun" "Sunday") 0)
+ ((or "Mon" "Monday") 1)
+ ((or "Tue" "Tuesday") 2)
+ ((or "Wed" "Wednesday") 3)
+ ((or "Thu" "Thursday") 4)
+ ((or "Fri" "Friday") 5)
+ ((or "Sat" "Saturday") 6)
+ (_ (error "Unknown day of week: %s" day)))))
+
(provide 'org-test)
;;; org-test.el ends here