Function: org-clock-timestamps-change
org-clock-timestamps-change is a byte-compiled function defined in
org-clock.el.gz.
Signature
(org-clock-timestamps-change UPDOWN &optional N)
Documentation
Change CLOCK timestamps synchronously at cursor.
UPDOWN tells whether to change up or down.
Optional argument N tells to change by that many units.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-clock.el.gz
(defun org-clock-timestamps-change (updown &optional n)
"Change CLOCK timestamps synchronously at cursor.
UPDOWN tells whether to change `up' or `down'.
Optional argument N tells to change by that many units."
(let ((tschange (if (eq updown 'up) 'org-timestamp-up
'org-timestamp-down))
(timestamp? (org-at-timestamp-p 'lax))
ts1 begts1 ts2 begts2 updatets1 tdiff)
(when timestamp?
(save-excursion
(move-beginning-of-line 1)
(re-search-forward org-ts-regexp3 nil t)
(setq ts1 (match-string 0) begts1 (match-beginning 0))
(when (re-search-forward org-ts-regexp3 nil t)
(setq ts2 (match-string 0) begts2 (match-beginning 0))))
;; Are we on the second timestamp?
(if (<= begts2 (point)) (setq updatets1 t))
(if (not ts2)
;; fall back on org-timestamp-up if there is only one
(funcall tschange n)
(funcall tschange n)
(let ((ts (if updatets1 ts2 ts1))
(begts (if updatets1 begts1 begts2)))
(setq tdiff
(time-subtract
(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
;; timestamp.
(let ((origin (point)))
(save-excursion
(goto-char begts)
(org-timestamp-change
(round (/ (float-time tdiff)
(pcase timestamp?
(`minute 60)
(`hour 3600)
(`day (* 24 3600))
(`month (* 24 3600 31))
(`year (* 24 3600 365.2)))))
timestamp? 'updown))
;; Move back to initial position, but never beyond updated
;; clock.
(unless (< (point) origin)
(goto-char origin))))))))