Function: org-modify-ts-extra
org-modify-ts-extra is a byte-compiled function defined in org.el.gz.
Signature
(org-modify-ts-extra S POS N DM)
Documentation
Change the different parts of the lead-time and repeat fields in timestamp.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-modify-ts-extra (s pos n dm)
"Change the different parts of the lead-time and repeat fields in timestamp."
(let ((idx '(("d" . 0) ("w" . 1) ("m" . 2) ("y" . 3) ("d" . -1) ("y" . 4)))
ng h m new rem)
(when (string-match "\\(-\\([012][0-9]\\):\\([0-5][0-9]\\)\\)?\\( +\\+\\([0-9]+\\)\\([dmwy]\\)\\)?\\( +-\\([0-9]+\\)\\([dmwy]\\)\\)?" s)
(cond
((or (org-pos-in-match-range pos 2)
(org-pos-in-match-range pos 3))
(setq m (string-to-number (match-string 3 s))
h (string-to-number (match-string 2 s)))
(if (org-pos-in-match-range pos 2)
(setq h (+ h n))
(setq n (* dm (with-no-warnings (cl-signum n))))
(unless (= 0 (setq rem (% m dm)))
(setq m (+ m (if (> n 0) (- rem) (- dm rem)))))
(setq m (+ m n)))
(when (< m 0) (setq m (+ m 60) h (1- h)))
(when (> m 59) (setq m (- m 60) h (1+ h)))
(setq h (mod h 24))
(setq ng 1 new (format "-%02d:%02d" h m)))
((org-pos-in-match-range pos 6)
(setq ng 6 new (car (rassoc (+ n (cdr (assoc (match-string 6 s) idx))) idx))))
((org-pos-in-match-range pos 5)
(setq ng 5 new (format "%d" (max 1 (+ n (string-to-number (match-string 5 s)))))))
((org-pos-in-match-range pos 9)
(setq ng 9 new (car (rassoc (+ n (cdr (assoc (match-string 9 s) idx))) idx))))
((org-pos-in-match-range pos 8)
(setq ng 8 new (format "%d" (max 0 (+ n (string-to-number (match-string 8 s))))))))
(when ng
(setq s (concat
(substring s 0 (match-beginning ng))
new
(substring s (match-end ng))))))
s))