From 3dc08309092580063d07f557218bed92b833913b Mon Sep 17 00:00:00 2001 From: Max Nikulin Date: Mon, 2 May 2022 21:19:59 +0700 Subject: [PATCH 6/6] Use `org-encode-time' helper macro * lisp/ol.el (org-store-link): * lisp/org-agenda.el (org-agenda-get-timestamps) (org-agenda-get-progress, agenda-bulk-action): * lisp/org-capture.el (org-capture-fill-template): * lisp/org-clock.el (org-clock-get-sum-start) (org-clock-special-range, org-clocktable-shift) (org-clocktable-steps): * lisp/org-colview.el (org-colview-construct-allowed-dates): * lisp/org-datetree.el (org-datetree-find-iso-week-create) (org-datetree-insert-line): * lisp/org-element.el (org-element-timestamp-interpreter): * lisp/org-macro.el (org-macro--vc-modified-time): * lisp/org-macs.el (org-matcher-time): * lisp/org.el (org-current-time, org-current-effective-time) (org-add-planning-info, org-read-date, org-read-date-display) (org-read-date-analyze, org-eval-in-calendar) (org-calendar-select, org-display-custom-time) (org-calendar-select-mouse, org-time-string-to-time) (org-time-from-absolute, org-at-clock-log-p) (org-date-from-calendar, org-get-cursor-date) (org-timestamp-to-time): * testing/lisp/test-org-clock.el (org-test-clock-create-timestamp): * lisp/ox-icalendar.el (org-icalendar-convert-timestamp): Avoid direct calls of `encode-time', use `org-encode-time' instead. Org supports Emacs-26, but the recommended way to call `encode-time' changed in Emacs-27. In Emacs-29 DST and TZ elements of the single list arguments became optional. In Org it is still convenient to call the function with separate arguments without explicit DST and TZ arguments. The `org-encode-time' should mitigate attempts to modernize Org code directly in the Emacs repository. --- lisp/ol.el | 2 +- lisp/org-agenda.el | 8 ++-- lisp/org-capture.el | 9 ++-- lisp/org-clock.el | 57 ++++++++++++------------ lisp/org-colview.el | 2 +- lisp/org-datetree.el | 8 ++-- lisp/org-element.el | 27 ++++++------ lisp/org-macro.el | 2 +- lisp/org-macs.el | 4 +- lisp/org.el | 79 ++++++++++++++++++---------------- lisp/ox-icalendar.el | 2 +- testing/lisp/test-org-clock.el | 8 ++-- 12 files changed, 108 insertions(+), 100 deletions(-) diff --git a/lisp/ol.el b/lisp/ol.el index 0de9c921b..3c3c71170 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -1618,7 +1618,7 @@ non-nil." (setq link (format-time-string (car org-time-stamp-formats) - (encode-time 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)))) + (org-encode-time 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)))) (org-link-store-props :type "calendar" :date cd))) ((eq major-mode 'w3-mode) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 0479a0e1f..afc2a1015 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5740,7 +5740,7 @@ displayed in agenda view." (substring (format-time-string (car org-time-stamp-formats) - (encode-time ; DATE bound by calendar + (org-encode-time ; DATE bound by calendar 0 0 0 (nth 1 date) (car date) (nth 2 date))) 1 11)) "\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[hdwmy]>\\)" @@ -6012,7 +6012,7 @@ then those holidays will be skipped." (substring (format-time-string (car org-time-stamp-formats) - (encode-time ; DATE bound by calendar + (org-encode-time ; DATE bound by calendar 0 0 0 (nth 1 date) (car date) (nth 2 date))) 1 11)))) (org-agenda-search-headline-for-time nil) @@ -11077,8 +11077,8 @@ The prefix arg is passed through to the command if possible." (ignore-errors (let* ((date (calendar-gregorian-from-absolute (+ (org-today) distance))) - (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) - (nth 2 date)))) + (time (org-encode-time + 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))) (org-agenda-schedule nil time)))))))) (?f diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 068e3eda2..eb45f7ef5 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1050,9 +1050,10 @@ Store them in the capture property list." prompt-time ;; Use 00:00 when no time is given for another ;; date than today? - (apply #'encode-time 0 0 - org-extend-today-until - (cl-cdddr (decode-time prompt-time))))) + (org-encode-time + (apply #'list + 0 0 org-extend-today-until + (cl-cdddr (decode-time prompt-time)))))) (time-to-days prompt-time))) (t ;; Current date, possibly corrected for late night @@ -1579,7 +1580,7 @@ by their respective `org-store-link-plist' properties if present." (time (let* ((c (or (org-capture-get :default-time) (current-time))) (d (decode-time c))) (if (< (nth 2 d) org-extend-today-until) - (encode-time 0 59 23 (1- (nth 3 d)) (nth 4 d) (nth 5 d)) + (org-encode-time 0 59 23 (1- (nth 3 d)) (nth 4 d) (nth 5 d)) c))) (v-t (format-time-string (org-time-stamp-format nil) time)) (v-T (format-time-string (org-time-stamp-format t) time)) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 9f80dea04..da5c310b7 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -1520,7 +1520,7 @@ The time is always returned as UTC." (day (nth 3 dt))) (if (< hour org-extend-today-until) (setf (nth 3 dt) (1- day))) (setf (nth 2 dt) org-extend-today-until) - (apply #'encode-time 0 0 (nthcdr 2 dt)))) + (org-encode-time (apply #'list 0 0 (nthcdr 2 dt))))) ((or (equal cmt "all") (and (or (not cmt) (equal cmt "auto")) (not lr))) @@ -2351,16 +2351,16 @@ have priority." (let* ((start (pcase key (`interactive (org-read-date nil t nil "Range start? ")) (`untilnow nil) - (_ (encode-time 0 m h d month y)))) + (_ (org-encode-time 0 m h d month y)))) (end (pcase key (`interactive (org-read-date nil t nil "Range end? ")) (`untilnow (current-time)) - (_ (encode-time 0 - m ;; (or m1 m) - (or h1 h) - (or d1 d) - (or month1 month) - (or y1 y))))) + (_ (org-encode-time 0 + m ;; (or m1 m) + (or h1 h) + (or d1 d) + (or month1 month) + (or y1 y))))) (text (pcase key ((or `day `today) (format-time-string "%A, %B %d, %Y" start)) @@ -2428,14 +2428,14 @@ the currently selected interval size." (cond (d (setq ins (format-time-string "%Y-%m-%d" - (encode-time 0 0 0 (+ d n) nil y)))) ;; m + (org-encode-time 0 0 0 (+ d n) nil y)))) ;; m ((and wp (string-match "w\\|W" wp) mw (> (length wp) 0)) (require 'cal-iso) (setq date (calendar-gregorian-from-absolute (calendar-iso-to-absolute (list (+ mw n) 1 y)))) (setq ins (format-time-string "%G-W%V" - (encode-time 0 0 0 (nth 1 date) (car date) (nth 2 date))))) + (org-encode-time 0 0 0 (nth 1 date) (car date) (nth 2 date))))) ((and wp (string-match "q\\|Q" wp) mw (> (length wp) 0)) (require 'cal-iso) ; if the 4th + 1 quarter is requested we flip to the 1st quarter of the next year @@ -2452,11 +2452,11 @@ the currently selected interval size." (calendar-iso-to-absolute (org-quarter-to-date (+ mw n) y)))) (setq ins (format-time-string (concat (number-to-string y) "-Q" (number-to-string (+ mw n))) - (encode-time 0 0 0 (nth 1 date) (car date) (nth 2 date))))) + (org-encode-time 0 0 0 (nth 1 date) (car date) (nth 2 date))))) (mw (setq ins (format-time-string "%Y-%m" - (encode-time 0 0 0 1 (+ mw n) y)))) + (org-encode-time 0 0 0 1 (+ mw n) y)))) (y (setq ins (number-to-string (+ y n)))))) (t (user-error "Cannot shift clocktable block"))) @@ -2844,7 +2844,7 @@ a number of clock tables." (pcase (if range (car range) (plist-get params :tstart)) ((and (pred numberp) n) (pcase-let ((`(,m ,d ,y) (calendar-gregorian-from-absolute n))) - (apply #'encode-time (list 0 0 org-extend-today-until d m y)))) + (org-encode-time 0 0 org-extend-today-until d m y))) (timestamp (seconds-to-time (org-matcher-time (or timestamp @@ -2854,7 +2854,7 @@ a number of clock tables." (pcase (if range (nth 1 range) (plist-get params :tend)) ((and (pred numberp) n) (pcase-let ((`(,m ,d ,y) (calendar-gregorian-from-absolute n))) - (apply #'encode-time (list 0 0 org-extend-today-until d m y)))) + (org-encode-time 0 0 org-extend-today-until d m y))) (timestamp (seconds-to-time (org-matcher-time timestamp)))))) (while (time-less-p start end) (unless (bolp) (insert "\n")) @@ -2866,20 +2866,21 @@ a number of clock tables." ;; Compute NEXT, which is the end of the current clock table, ;; according to step. (let* ((next - (apply #'encode-time - (pcase-let - ((`(,_ ,_ ,_ ,d ,m ,y ,dow . ,_) (decode-time start))) - (pcase step - (`day (list 0 0 org-extend-today-until (1+ d) m y)) - (`week - (let ((offset (if (= dow week-start) 7 - (mod (- week-start dow) 7)))) - (list 0 0 org-extend-today-until (+ d offset) m y))) - (`semimonth (list 0 0 0 - (if (< d 16) 16 1) - (if (< d 16) m (1+ m)) y)) - (`month (list 0 0 0 month-start (1+ m) y)) - (`year (list 0 0 org-extend-today-until 1 1 (1+ y))))))) + ;; In Emacs-27 and Emacs-28 `encode-time' does not support 6 elements + ;; list argument so `org-encode-time' can not be outside of `pcase'. + (pcase-let + ((`(,_ ,_ ,_ ,d ,m ,y ,dow . ,_) (decode-time start))) + (pcase step + (`day (org-encode-time 0 0 org-extend-today-until (1+ d) m y)) + (`week + (let ((offset (if (= dow week-start) 7 + (mod (- week-start dow) 7)))) + (org-encode-time 0 0 org-extend-today-until (+ d offset) m y))) + (`semimonth (org-encode-time 0 0 0 + (if (< d 16) 16 1) + (if (< d 16) m (1+ m)) y)) + (`month (org-encode-time 0 0 0 month-start (1+ m) y)) + (`year (org-encode-time 0 0 org-extend-today-until 1 1 (1+ y)))))) (table-begin (line-beginning-position 0)) (step-time ;; Write clock table between START and NEXT. diff --git a/lisp/org-colview.el b/lisp/org-colview.el index c8443c135..c29a29d51 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -784,7 +784,7 @@ around it." (setq time-after (copy-sequence time)) (setf (nth 3 time-before) (1- (nth 3 time))) (setf (nth 3 time-after) (1+ (nth 3 time))) - (mapcar (lambda (x) (format-time-string fmt (apply #'encode-time x))) + (mapcar (lambda (x) (format-time-string fmt (org-encode-time x))) (list time-before time time-after))))) (defun org-columns-open-link (&optional arg) diff --git a/lisp/org-datetree.el b/lisp/org-datetree.el index 30f5f99ae..f0c6bb7ba 100644 --- a/lisp/org-datetree.el +++ b/lisp/org-datetree.el @@ -137,7 +137,7 @@ will be built under the headline at point." (let* ((year (calendar-extract-year d)) (month (calendar-extract-month d)) (day (calendar-extract-day d)) - (time (encode-time 0 0 0 day month year)) + (time (org-encode-time 0 0 0 day month year)) (iso-date (calendar-iso-from-absolute (calendar-absolute-from-gregorian d))) (weekyear (nth 2 iso-date)) @@ -197,14 +197,14 @@ inserted into the buffer." (when month (insert (if day - (format-time-string "-%m-%d %A" (encode-time 0 0 0 day month year)) - (format-time-string "-%m %B" (encode-time 0 0 0 1 month year)))))) + (format-time-string "-%m-%d %A" (org-encode-time 0 0 0 day month year)) + (format-time-string "-%m %B" (org-encode-time 0 0 0 1 month year)))))) (when (and day org-datetree-add-timestamp) (save-excursion (insert "\n") (org-indent-line) (org-insert-time-stamp - (encode-time 0 0 0 day month year) + (org-encode-time 0 0 0 day month year) nil (eq org-datetree-add-timestamp 'inactive)))) (beginning-of-line)) diff --git a/lisp/org-element.el b/lisp/org-element.el index 3856079aa..c40761657 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -4041,12 +4041,12 @@ Assume point is at the beginning of the timestamp." (/= minute-start minute-end))))) (funcall build-ts-string - (encode-time 0 - (or minute-start 0) - (or hour-start 0) - (org-element-property :day-start timestamp) - (org-element-property :month-start timestamp) - (org-element-property :year-start timestamp)) + (org-encode-time 0 + (or minute-start 0) + (or hour-start 0) + (org-element-property :day-start timestamp) + (org-element-property :month-start timestamp) + (org-element-property :year-start timestamp)) (eq type 'active) (and hour-start minute-start) (and time-range-p hour-end) @@ -4058,7 +4058,7 @@ Assume point is at the beginning of the timestamp." (hour-end (org-element-property :hour-end timestamp))) (concat (funcall - build-ts-string (encode-time + build-ts-string (org-encode-time 0 (or minute-start 0) (or hour-start 0) @@ -4069,12 +4069,13 @@ Assume point is at the beginning of the timestamp." (and hour-start minute-start)) "--" (funcall build-ts-string - (encode-time 0 - (or minute-end 0) - (or hour-end 0) - (org-element-property :day-end timestamp) - (org-element-property :month-end timestamp) - (org-element-property :year-end timestamp)) + (org-encode-time + 0 + (or minute-end 0) + (or hour-end 0) + (org-element-property :day-end timestamp) + (org-element-property :month-end timestamp) + (org-element-property :year-end timestamp)) (eq type 'active-range) (and hour-end minute-end))))) (_ (org-element-property :raw-value timestamp))))) diff --git a/lisp/org-macro.el b/lisp/org-macro.el index 1d5cbe1b4..04e1ef36e 100644 --- a/lisp/org-macro.el +++ b/lisp/org-macro.el @@ -387,7 +387,7 @@ Return value as a string." (buffer-substring (point) (line-end-position))))) (when (cl-some #'identity time) - (setq date (apply #'encode-time time)))))))) + (setq date (org-encode-time time)))))))) (let ((proc (get-buffer-process buf))) (while (and proc (accept-process-output proc .5 nil t))))) (kill-buffer buf)) diff --git a/lisp/org-macs.el b/lisp/org-macs.el index aec3c3adb..0b6d57720 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -1457,8 +1457,8 @@ following special strings: \"\", \"\", \"\", and \"\". Return 0. if S is not recognized as a valid value." - (let ((today (float-time (apply #'encode-time - (append '(0 0 0) (nthcdr 3 (decode-time))))))) + (let ((today (float-time (org-encode-time + (append '(0 0 0) (nthcdr 3 (decode-time))))))) (save-match-data (cond ((string= s "") (float-time)) diff --git a/lisp/org.el b/lisp/org.el index 165c83609..3288bb7b8 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4767,8 +4767,10 @@ the rounding returns a past time." (if (< r 1) now (let* ((time (decode-time now)) - (res (apply #'encode-time 0 (* r (round (nth 1 time) r)) - (nthcdr 2 time)))) + (res (org-encode-time + (apply #'list + 0 (* r (round (nth 1 time) r)) + (nthcdr 2 time))))) (if (or (not past) (time-less-p res now)) res (time-subtract res (* r 60))))))) @@ -8778,7 +8780,7 @@ nil or a string to be used for the todo mark." ) (org-use-last-clock-out-time-as-effective-time (or (org-clock-get-last-clock-out-time) ct)) ((and org-use-effective-time (< (nth 2 dct) org-extend-today-until)) - (encode-time 0 59 23 (1- (nth 3 dct)) (nth 4 dct) (nth 5 dct))) + (org-encode-time 0 59 23 (1- (nth 3 dct)) (nth 4 dct) (nth 5 dct))) (t ct)))) ct1)) @@ -9931,9 +9933,9 @@ WHAT entry will also be removed." (if (stringp time) ;; This is a string (relative or absolute), set ;; proper date. - (apply #'encode-time - (org-read-date-analyze - time default-time (decode-time default-time))) + (org-encode-time + (org-read-date-analyze + time default-time (decode-time default-time))) ;; If necessary, get the time from the user (or time (org-read-date nil 'to-time nil (cl-case what @@ -13315,7 +13317,7 @@ user." (when (< (nth 2 org-defdecode) org-extend-today-until) (setf (nth 2 org-defdecode) -1) (setf (nth 1 org-defdecode) 59) - (setq org-def (apply #'encode-time org-defdecode)) + (setq org-def (org-encode-time org-defdecode)) (setq org-defdecode (decode-time org-def))) (let* ((timestr (format-time-string (if org-with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") @@ -13388,7 +13390,7 @@ user." "range representable on this machine")) (ding)) - (setq final (apply #'encode-time final)) + (setq final (org-encode-time final)) (setq org-read-date-final-answer ans) @@ -13425,7 +13427,7 @@ user." (and (boundp 'org-time-was-given) org-time-was-given)) (cdr fmts) (car fmts))) - (txt (format-time-string fmt (apply #'encode-time f))) + (txt (format-time-string fmt (org-encode-time f))) (txt (if org-read-date-inactive (concat "[" (substring txt 1 -1) "]") txt)) (txt (concat "=> " txt))) (when (and org-end-time-was-given @@ -13643,7 +13645,7 @@ user." ((and wday (not (nth 3 tl))) ;; Weekday was given, but no day, so pick that day in the week ;; on or after the derived date. - (setq wday1 (nth 6 (decode-time (encode-time 0 0 0 day month year)))) + (setq wday1 (nth 6 (decode-time (org-encode-time 0 0 0 day month year)))) (unless (equal wday wday1) (setq day (+ day (% (- wday wday1 -7) 7)))))) (when (and (boundp 'org-time-was-given) @@ -13658,7 +13660,7 @@ user." (when (> year 2037) (setq year 2037 org-read-date-analyze-forced-year t))) (condition-case nil - (ignore (encode-time second minute hour day month year)) + (ignore (org-encode-time second minute hour day month year)) (error (setq year (nth 5 org-defdecode)) (setq org-read-date-analyze-forced-year t)))) @@ -13723,7 +13725,7 @@ Unless KEEPDATE is non-nil, update `org-ans2' to the cursor date." (eval form t) (when (and (not keepdate) (calendar-cursor-to-date)) (let* ((date (calendar-cursor-to-date)) - (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))) + (time (org-encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))) (setq org-ans2 (format-time-string "%Y-%m-%d" time)))) (move-overlay org-date-ovl (1- (point)) (1+ (point)) (current-buffer)) (select-window sw) @@ -13735,7 +13737,7 @@ This is used by `org-read-date' in a temporary keymap for the calendar buffer." (interactive) (when (calendar-cursor-to-date) (let* ((date (calendar-cursor-to-date)) - (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))) + (time (org-encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))) (setq org-ans1 (format-time-string "%Y-%m-%d" time))) (when (active-minibuffer-window) (exit-minibuffer)))) @@ -13800,7 +13802,7 @@ The command returns the inserted time stamp." time (org-fix-decoded-time t1) str (org-add-props (format-time-string - (substring tf 1 -1) (apply 'encode-time time)) + (substring tf 1 -1) (org-encode-time time)) nil 'mouse-face 'highlight)) (put-text-property beg end 'display str))) @@ -13854,7 +13856,7 @@ This is used by `org-read-date' in a temporary keymap for the calendar buffer." (mouse-set-point ev) (when (calendar-cursor-to-date) (let* ((date (calendar-cursor-to-date)) - (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))) + (time (org-encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))) (setq org-ans1 (format-time-string "%Y-%m-%d" time))) (when (active-minibuffer-window) (exit-minibuffer)))) @@ -14055,7 +14057,7 @@ days in order to avoid rounding problems." (defun org-time-string-to-time (s) "Convert timestamp string S into internal time." - (apply #'encode-time (org-parse-time-string s))) + (org-encode-time (org-parse-time-string s))) (defun org-time-string-to-seconds (s) "Convert a timestamp string S into a number of seconds." @@ -14118,7 +14120,7 @@ into a past one. Any year larger than 99 is returned unchanged." "Return the time corresponding to date D. D may be an absolute day number, or a calendar-type list (month day year)." (when (numberp d) (setq d (calendar-gregorian-from-absolute d))) - (encode-time 0 0 0 (nth 1 d) (car d) (nth 2 d))) + (org-encode-time 0 0 0 (nth 1 d) (car d) (nth 2 d))) (defvar org-agenda-current-date) (defun org-calendar-holiday () @@ -14472,14 +14474,15 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays like (setcar (cdr time0) (+ (nth 1 time0) (if (> n 0) (- rem) (- dm rem)))))) (setq time - (apply #'encode-time - (or (car time0) 0) - (+ (if (eq timestamp? 'minute) n 0) (nth 1 time0)) - (+ (if (eq timestamp? 'hour) n 0) (nth 2 time0)) - (+ (if (eq timestamp? 'day) n 0) (nth 3 time0)) - (+ (if (eq timestamp? 'month) n 0) (nth 4 time0)) - (+ (if (eq timestamp? 'year) n 0) (nth 5 time0)) - (nthcdr 6 time0))) + (org-encode-time + (apply #'list + (or (car time0) 0) + (+ (if (eq timestamp? 'minute) n 0) (nth 1 time0)) + (+ (if (eq timestamp? 'hour) n 0) (nth 2 time0)) + (+ (if (eq timestamp? 'day) n 0) (nth 3 time0)) + (+ (if (eq timestamp? 'month) n 0) (nth 4 time0)) + (+ (if (eq timestamp? 'year) n 0) (nth 5 time0)) + (nthcdr 6 time0)))) (when (and (memq timestamp? '(hour minute)) extra (string-match "-\\([012][0-9]\\):\\([0-5][0-9]\\)" extra)) @@ -14497,7 +14500,7 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays like (setcar time0 (or (car time0) 0)) (setcar (nthcdr 1 time0) (or (nth 1 time0) 0)) (setcar (nthcdr 2 time0) (or (nth 2 time0) 0)) - (setq time (apply 'encode-time time0)))) + (setq time (org-encode-time time0)))) ;; Insert the new time-stamp, and ensure point stays in the same ;; category as before (i.e. not after the last position in that ;; category). @@ -14643,7 +14646,7 @@ If there is already a time stamp at the cursor position, update it." (org-timestamp-change 0 'calendar) (let ((cal-date (org-get-date-from-calendar))) (org-insert-time-stamp - (encode-time 0 0 0 (nth 1 cal-date) (car cal-date) (nth 2 cal-date)))))) + (org-encode-time 0 0 0 (nth 1 cal-date) (car cal-date) (nth 2 cal-date)))))) (defcustom org-image-actual-width t "When non-nil, use the actual width of images when inlining them. @@ -18204,14 +18207,14 @@ earliest time on the cursor date that Org treats as that date (cond ((eq major-mode 'calendar-mode) (setq date (calendar-cursor-to-date) - defd (encode-time 0 (or mod 0) (or hod org-extend-today-until) - (nth 1 date) (nth 0 date) (nth 2 date)))) + defd (org-encode-time 0 (or mod 0) (or hod org-extend-today-until) + (nth 1 date) (nth 0 date) (nth 2 date)))) ((eq major-mode 'org-agenda-mode) (setq day (get-text-property (point) 'day)) (when day (setq date (calendar-gregorian-from-absolute day) - defd (encode-time 0 (or mod 0) (or hod org-extend-today-until) - (nth 1 date) (nth 0 date) (nth 2 date)))))) + defd (org-encode-time 0 (or mod 0) (or hod org-extend-today-until) + (nth 1 date) (nth 0 date) (nth 2 date)))))) (or defd (current-time)))) (defun org-mark-subtree (&optional up) @@ -19276,12 +19279,14 @@ return an active timestamp." "Convert TIMESTAMP object into an Emacs internal time value. Use end of date range or time range when END is non-nil. Otherwise, use its start." - (apply #'encode-time 0 - (mapcar - (lambda (prop) (or (org-element-property prop timestamp) 0)) - (if end '(:minute-end :hour-end :day-end :month-end :year-end) - '(:minute-start :hour-start :day-start :month-start - :year-start))))) + (org-encode-time + (append '(0) + (mapcar + (lambda (prop) (or (org-element-property prop timestamp) 0)) + (if end '(:minute-end :hour-end :day-end :month-end :year-end) + '(:minute-start :hour-start :day-start :month-start + :year-start))) + '(nil -1 nil)))) (defun org-timestamp-has-time-p (timestamp) "Non-nil when TIMESTAMP has a time specified." diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el index abf31ce65..daac323cb 100644 --- a/lisp/ox-icalendar.el +++ b/lisp/ox-icalendar.el @@ -430,7 +430,7 @@ format (e.g. \"Europe/London\"). In either case, the value of t))) ;; Convert timestamp into internal time in order to use ;; `format-time-string' and fix any mistake (i.e. MI >= 60). - (encode-time 0 mi h d m y) + (org-encode-time 0 mi h d m y) (and (or (string-equal tz "UTC") (and (null tz) with-time-p diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el index d2179e1ec..9650b8c8d 100644 --- a/testing/lisp/test-org-clock.el +++ b/testing/lisp/test-org-clock.el @@ -26,10 +26,10 @@ insert hours and minutes. Return the timestamp as a string." (org-element-interpret-data (let ((time (decode-time - (apply #'encode-time - (mapcar (lambda (el) (or el 0)) - (org-read-date-analyze - input nil (decode-time (current-time)))))))) + (org-encode-time + (mapcar (lambda (el) (or el 0)) + (org-read-date-analyze + input nil (decode-time (current-time)))))))) (list 'timestamp (list :type (if inactive 'inactive 'active) :minute-start (and with-time (nth 1 time)) -- 2.25.1