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'.
This commit is contained in:
parent
8739a95782
commit
9730f408c2
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue