branch: externals/org commit 236bd4584904428dfc209c318788edc30e8d5b9d Merge: d94f4066e0 7a90f596d9 Author: Ihor Radchenko <yanta...@posteo.net> Commit: Ihor Radchenko <yanta...@posteo.net>
Merge branch 'bugfix' --- lisp/org-clock.el | 6 +++++- testing/lisp/test-org-clock.el | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index f869b0b7a0..d464585360 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -1800,7 +1800,11 @@ Optional argument N tells to change by that many units." (begts (if updatets1 begts1 begts2))) (setq tdiff (time-subtract - (org-time-string-to-time org-last-changed-timestamp) + (org-time-string-to-time + (save-excursion + (goto-char (if updatets1 begts2 begts1)) + (looking-at org-ts-regexp3) + (match-string 0))) (org-time-string-to-time ts))) ;; `save-excursion' won't work because ;; `org-timestamp-change' deletes and re-inserts the diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el index 68286b1744..f732e471a3 100644 --- a/testing/lisp/test-org-clock.el +++ b/testing/lisp/test-org-clock.el @@ -89,6 +89,30 @@ the buffer." ;; Remove clocktable. (delete-region (point) (search-forward "#+END:\n")))) +(ert-deftest test-org-clok/org-clock-timestamps-change () + "Test `org-clock-timestamps-change' specifications." + (should + (equal + "CLOCK: [2023-02-19 Sun 21:30]--[2023-02-19 Sun 23:35] => 2:05" + (org-test-with-temp-text + "CLOCK: [2023-02-19 Sun 2<point>2:30]--[2023-02-20 Mon 00:35] => 2:05" + (org-clock-timestamps-change 'down 1) + (buffer-string)))) + (should + (equal + "CLOCK: [2023-02-20 Mon 00:00]--[2023-02-20 Mon 00:40] => 0:40" + (org-test-with-temp-text + "CLOCK: [2023-02-19 Sun 23:<point>55]--[2023-02-20 Mon 00:35] => 0:40" + (org-clock-timestamps-change 'up 1) + (buffer-string)))) + (should + (equal + "CLOCK: [2023-02-20 Mon 00:30]--[2023-02-20 Mon 01:35] => 1:05" + (org-test-with-temp-text + "CLOCK: [2023-02-19 Sun 2<point>3:30]--[2023-02-20 Mon 00:35] => 1:05" + (org-clock-timestamps-change 'up 1) + (buffer-string))))) + ;;; Clock drawer