[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 988e37f 3/4: Simplify use of encode-time
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master 988e37f 3/4: Simplify use of encode-time |
Date: |
Mon, 11 Feb 2019 02:54:42 -0500 (EST) |
branch: master
commit 988e37fa0f922b852715671d59a0e3f682373411
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
Simplify use of encode-time
Most uses of (apply #'encode-time foo) can now be replaced
with (encode-time foo). Make similar simplifications.
* lisp/calendar/time-date.el (date-to-time):
* lisp/calendar/timeclock.el (timeclock-when-to-leave)
(timeclock-day-base, timeclock-generate-report):
* lisp/emacs-lisp/timer.el (timer-set-idle-time):
* lisp/eshell/esh-util.el (eshell-parse-ange-ls):
* lisp/gnus/gnus-art.el (article-make-date-line):
* lisp/gnus/gnus-delay.el (gnus-delay-article)
(gnus-delay-send-queue):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event--decode-datefield):
* lisp/gnus/gnus-logic.el (gnus-advanced-date):
* lisp/gnus/message.el (message-make-expires-date):
* lisp/gnus/nndiary.el (nndiary-compute-reminders):
* lisp/mail/ietf-drums.el (ietf-drums-parse-date):
* lisp/net/tramp-adb.el (tramp-adb-ls-output-time-less-p):
* lisp/org/org-agenda.el (org-agenda-get-timestamps)
(org-agenda-get-progress, org-agenda-show-clocking-issues):
* lisp/org/org-capture.el (org-capture-set-target-location):
* lisp/org/org-clock.el (org-clock-get-sum-start, org-clock-sum)
(org-clocktable-steps):
* lisp/org/org-colview.el (org-colview-construct-allowed-dates)
* lisp/org/org-macro.el (org-macro--vc-modified-time):
* lisp/org/org-table.el (org-table-eval-formula):
* lisp/org/org.el (org-current-time, org-store-link)
(org-time-today, org-read-date, org-read-date-display)
(org-display-custom-time, org-time-string-to-time)
(org-timestamp-change, org-timestamp--to-internal-time):
* lisp/url/url-dav.el (url-dav-process-date-property):
* lisp/vc/vc-cvs.el (vc-cvs-annotate-current-time)
(vc-cvs-parse-entry):
Simplify use of encode-time.
* lisp/org/org-clock.el (org-clock-get-clocked-time):
(org-clock-resolve, org-resolve-clocks, org_clock_out)
(org-clock-update-time-maybe):
Avoid some rounding problems with encode-time and float-time.
* lisp/org/org-clock.el (org-clock-in, org-clock-update-time-maybe):
* lisp/org/org-colview.el (org-columns--age-to-minutes):
* lisp/org/org.el (org-get-scheduled-time, org-get-deadline-time)
(org-add-planning-info, org-2ft, org-time-string-to-absolute)
(org-closest-date):
Use org-time-string-to-time instead of doing it by hand with
encode-time.
* lisp/org/org.el (org-current-time): Simplify rounding.
(org-read-date): Avoid extra trip through encode-time.
---
lisp/calendar/time-date.el | 7 ++---
lisp/calendar/timeclock.el | 37 +++++++++---------------
lisp/emacs-lisp/timer.el | 2 +-
lisp/eshell/esh-util.el | 2 +-
lisp/gnus/gnus-art.el | 2 +-
lisp/gnus/gnus-delay.el | 22 ++++++--------
lisp/gnus/gnus-icalendar.el | 2 +-
lisp/gnus/gnus-logic.el | 6 ++--
lisp/gnus/message.el | 2 +-
lisp/gnus/nndiary.el | 12 ++++----
lisp/mail/ietf-drums.el | 2 +-
lisp/net/soap-client.el | 2 +-
lisp/net/tramp-adb.el | 4 +--
lisp/org/org-agenda.el | 14 ++++-----
lisp/org/org-capture.el | 5 ++--
lisp/org/org-clock.el | 58 +++++++++++++++++--------------------
lisp/org/org-colview.el | 4 +--
lisp/org/org-macro.el | 2 +-
lisp/org/org-table.el | 4 +--
lisp/org/org.el | 70 +++++++++++++++++++++------------------------
lisp/url/url-dav.el | 2 +-
lisp/vc/vc-cvs.el | 7 ++---
22 files changed, 119 insertions(+), 149 deletions(-)
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el
index 6fb0f22..cc30bd1 100644
--- a/lisp/calendar/time-date.el
+++ b/lisp/calendar/time-date.el
@@ -151,15 +151,14 @@ it is assumed that PICO was omitted and should be treated
as zero."
DATE should be in one of the forms recognized by `parse-time-string'.
If DATE lacks timezone information, GMT is assumed."
(condition-case err
- (apply 'encode-time (parse-time-string date))
+ (encode-time (parse-time-string date))
(error
(let ((overflow-error '(error "Specified time is not representable")))
(if (equal err overflow-error)
(apply 'signal err)
(condition-case err
- (apply 'encode-time
- (parse-time-string
- (timezone-make-date-arpa-standard date)))
+ (encode-time (parse-time-string
+ (timezone-make-date-arpa-standard date)))
(error
(if (equal err overflow-error)
(apply 'signal err)
diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el
index fd6f531..5c3580d 100644
--- a/lisp/calendar/timeclock.el
+++ b/lisp/calendar/timeclock.el
@@ -528,14 +528,13 @@ non-nil, the amount returned will be relative to past
time worked."
"Return a time value representing the end of today's workday.
If TODAY-ONLY is non-nil, the value returned will be relative only to
the time worked today, and not to past time."
- (encode-time
- (- (float-time)
- (let ((discrep (timeclock-find-discrep)))
- (if discrep
- (if today-only
- (cadr discrep)
- (car discrep))
- 0.0)))))
+ (time-subtract nil
+ (let ((discrep (timeclock-find-discrep)))
+ (if discrep
+ (if today-only
+ (cadr discrep)
+ (car discrep))
+ 0))))
;;;###autoload
(defun timeclock-when-to-leave-string (&optional show-seconds
@@ -1156,7 +1155,7 @@ If optional argument TIME is non-nil, use that instead of
the current time."
(setcar (nthcdr 0 decoded) 0)
(setcar (nthcdr 1 decoded) 0)
(setcar (nthcdr 2 decoded) 0)
- (apply 'encode-time decoded)))
+ (encode-time decoded)))
(defun timeclock-mean (l)
"Compute the arithmetic mean of the values in the list L."
@@ -1196,9 +1195,7 @@ HTML-P is non-nil, HTML markup is added."
(insert project "</b><br>\n")
(insert project "*\n"))
(let ((proj-data (cdr (assoc project (timeclock-project-alist log))))
- (two-weeks-ago (encode-time
- (- (float-time today)
- (* 2 7 24 60 60))))
+ (two-weeks-ago (time-subtract today (* 2 7 24 60 60)))
two-week-len today-len)
(while proj-data
(if (not (time-less-p
@@ -1249,18 +1246,10 @@ HTML-P is non-nil, HTML markup is added."
<th>-1 year</th>
</tr>")
(let* ((day-list (timeclock-day-list))
- (thirty-days-ago (encode-time
- (- (float-time today)
- (* 30 24 60 60))))
- (three-months-ago (encode-time
- (- (float-time today)
- (* 90 24 60 60))))
- (six-months-ago (encode-time
- (- (float-time today)
- (* 180 24 60 60))))
- (one-year-ago (encode-time
- (- (float-time today)
- (* 365 24 60 60))))
+ (thirty-days-ago (time-subtract today (* 30 24 60 60)))
+ (three-months-ago (time-subtract today (* 90 24 60 60)))
+ (six-months-ago (time-subtract today (* 180 24 60 60)))
+ (one-year-ago (time-subtract today (* 365 24 60 60)))
(time-in (vector (list t) (list t) (list t) (list t) (list t)))
(time-out (vector (list t) (list t) (list t) (list t) (list t)))
(breaks (vector (list t) (list t) (list t) (list t) (list t)))
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el
index f77c945..51d7e6f 100644
--- a/lisp/emacs-lisp/timer.el
+++ b/lisp/emacs-lisp/timer.el
@@ -88,7 +88,7 @@ SECS may be an integer, floating point number, or the internal
time format returned by, e.g., `current-idle-time'.
If optional third argument REPEAT is non-nil, make the timer
fire each time Emacs is idle for that many seconds."
- (setf (timer--time timer) (if (consp secs) secs (encode-time secs)))
+ (setf (timer--time timer) secs)
(setf (timer--repeat-delay timer) repeat)
timer)
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index 7e6e39e..118978e 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -652,7 +652,7 @@ If NOSORT is non-nil, the list is not sorted--its order is
unpredictable.
(setcar (nthcdr 0 moment) 0)
(setcar (nthcdr 1 moment) 0)
(setcar (nthcdr 2 moment) 0))
- (apply 'encode-time moment))
+ (encode-time moment))
(ange-ftp-file-modtime (expand-file-name name dir))))
symlink)
(if (string-match "\\(.+\\) -> \\(.+\\)" name)
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index e390118..191f623 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -3544,7 +3544,7 @@ possible values."
(substring
(message-make-date
(let* ((e (parse-time-string date))
- (tm (apply 'encode-time e))
+ (tm (encode-time e))
(ms (car tm))
(ls (- (cadr tm) (car (current-time-zone time)))))
(cond ((< ls 0) (list (1- ms) (+ ls 65536)))
diff --git a/lisp/gnus/gnus-delay.el b/lisp/gnus/gnus-delay.el
index e013f26..aabf239 100644
--- a/lisp/gnus/gnus-delay.el
+++ b/lisp/gnus/gnus-delay.el
@@ -98,19 +98,15 @@ DELAY is a string, giving the length of the time. Possible
values are:
(setq hour (string-to-number (match-string 1 delay))
minute (string-to-number (match-string 2 delay)))
;; Use current time, except...
- (setq deadline (apply 'vector (decode-time)))
+ (setq deadline (decode-time))
;; ... for minute and hour.
- (aset deadline 1 minute)
- (aset deadline 2 hour)
- ;; Convert to seconds.
- (setq deadline (float-time (apply 'encode-time
- (append deadline nil))))
+ (setq deadline (apply #'encode-time (car deadline) minute hour
+ (nthcdr 3 deadline)))
;; If this time has passed already, add a day.
- (when (< deadline (float-time))
- (setq deadline (+ 86400 deadline))) ; 86400 secs/day
+ (when (time-less-p deadline nil)
+ (setq deadline (time-add 86400 deadline))) ; 86400 secs/day
;; Convert seconds to date header.
- (setq deadline (message-make-date
- (encode-time deadline))))
+ (setq deadline (message-make-date deadline)))
((string-match "\\([0-9]+\\)\\s-*\\([mhdwMY]\\)" delay)
(setq num (match-string 1 delay))
(setq unit (match-string 2 delay))
@@ -128,8 +124,7 @@ DELAY is a string, giving the length of the time. Possible
values are:
(setq delay (* num 60 60)))
(t
(setq delay (* num 60))))
- (setq deadline (message-make-date
- (encode-time (+ (float-time) delay)))))
+ (setq deadline (message-make-date (time-add nil delay))))
(t (error "Malformed delay `%s'" delay)))
(message-add-header (format "%s: %s" gnus-delay-header deadline)))
(set-buffer-modified-p t)
@@ -164,8 +159,7 @@ DELAY is a string, giving the length of the time. Possible
values are:
nil t)
(progn
(setq deadline (nnheader-header-value))
- (setq deadline (apply 'encode-time
- (parse-time-string deadline)))
+ (setq deadline (encode-time (parse-time-string deadline)))
(unless (time-less-p nil deadline)
(message "Sending delayed article %d" article)
(gnus-draft-send article group)
diff --git a/lisp/gnus/gnus-icalendar.el b/lisp/gnus/gnus-icalendar.el
index e39561e..06f0927 100644
--- a/lisp/gnus/gnus-icalendar.el
+++ b/lisp/gnus/gnus-icalendar.el
@@ -147,7 +147,7 @@
(icalendar--get-event-property-attributes
event field) zone-map))
(dtdate-dec (icalendar--decode-isodatetime dtdate nil dtdate-zone)))
- (apply 'encode-time dtdate-dec)))
+ (encode-time dtdate-dec)))
(defun gnus-icalendar-event--find-attendee (ical name-or-email)
(let* ((event (car (icalendar--all-events ical)))
diff --git a/lisp/gnus/gnus-logic.el b/lisp/gnus/gnus-logic.el
index 8bf15cf..90f7420 100644
--- a/lisp/gnus/gnus-logic.el
+++ b/lisp/gnus/gnus-logic.el
@@ -162,9 +162,9 @@
(funcall type (or (aref gnus-advanced-headers index) 0) match)))
(defun gnus-advanced-date (index match type)
- (let ((date (apply 'encode-time (parse-time-string
- (aref gnus-advanced-headers index))))
- (match (apply 'encode-time (parse-time-string match))))
+ (let ((date (encode-time (parse-time-string
+ (aref gnus-advanced-headers index))))
+ (match (encode-time (parse-time-string match))))
(cond
((eq type 'at)
(equal date match))
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 9d5445c..b067452 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -5542,7 +5542,7 @@ In posting styles use `(\"Expires\" (make-expires-date
30))'."
(let* ((cur (decode-time))
(nday (+ days (nth 3 cur))))
(setf (nth 3 cur) nday)
- (message-make-date (apply 'encode-time cur))))
+ (message-make-date (encode-time cur))))
(defun message-make-message-id ()
"Make a unique Message-ID."
diff --git a/lisp/gnus/nndiary.el b/lisp/gnus/nndiary.el
index 3798be1..c8b7eed 100644
--- a/lisp/gnus/nndiary.el
+++ b/lisp/gnus/nndiary.el
@@ -1278,27 +1278,27 @@ all. This may very well take some time.")
(push
(cond ((eq (cdr reminder) 'minute)
(time-subtract
- (apply 'encode-time 0 (nthcdr 1 date-elts))
+ (apply #'encode-time 0 (nthcdr 1 date-elts))
(encode-time (* (car reminder) 60.0))))
((eq (cdr reminder) 'hour)
(time-subtract
- (apply 'encode-time 0 0 (nthcdr 2 date-elts))
+ (apply #'encode-time 0 0 (nthcdr 2 date-elts))
(encode-time (* (car reminder) 3600.0))))
((eq (cdr reminder) 'day)
(time-subtract
- (apply 'encode-time 0 0 0 (nthcdr 3 date-elts))
+ (apply #'encode-time 0 0 0 (nthcdr 3 date-elts))
(encode-time (* (car reminder) 86400.0))))
((eq (cdr reminder) 'week)
(time-subtract
- (apply 'encode-time 0 0 0 monday (nthcdr 4 date-elts))
+ (apply #'encode-time 0 0 0 monday (nthcdr 4 date-elts))
(encode-time (* (car reminder) 604800.0))))
((eq (cdr reminder) 'month)
(time-subtract
- (apply 'encode-time 0 0 0 1 (nthcdr 4 date-elts))
+ (apply #'encode-time 0 0 0 1 (nthcdr 4 date-elts))
(encode-time (* (car reminder) 18748800.0))))
((eq (cdr reminder) 'year)
(time-subtract
- (apply 'encode-time 0 0 0 1 1 (nthcdr 5 date-elts))
+ (apply #'encode-time 0 0 0 1 1 (nthcdr 5 date-elts))
(encode-time (* (car reminder) 400861056.0)))))
res))
(sort res 'time-less-p)))
diff --git a/lisp/mail/ietf-drums.el b/lisp/mail/ietf-drums.el
index 6600657..81377c9 100644
--- a/lisp/mail/ietf-drums.el
+++ b/lisp/mail/ietf-drums.el
@@ -294,7 +294,7 @@ a list of address strings."
(defun ietf-drums-parse-date (string)
"Return an Emacs time spec from STRING."
- (apply 'encode-time (parse-time-string string)))
+ (encode-time (parse-time-string string)))
(defun ietf-drums-narrow-to-header ()
"Narrow to the header section in the current buffer."
diff --git a/lisp/net/soap-client.el b/lisp/net/soap-client.el
index db8ed16..1632ee1 100644
--- a/lisp/net/soap-client.el
+++ b/lisp/net/soap-client.el
@@ -629,7 +629,7 @@ disallows them."
(<= time-zone-minute 59))
(error "Invalid or unsupported time: %s" date-time-string))
;; Return a value in a format similar to that returned by decode-time, and
- ;; suitable for (apply 'encode-time ...).
+ ;; suitable for (apply #'encode-time ...).
(list second minute hour day month year second-fraction datatype
(if has-time-zone
(* (rng-xsd-time-to-seconds
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index b9b1e4a..34faf4c 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -488,9 +488,9 @@ Emacs dired can't find files."
"Sort \"ls\" output by time, descending."
(let (time-a time-b)
(string-match tramp-adb-ls-date-regexp a)
- (setq time-a (apply 'encode-time (parse-time-string (match-string 0 a))))
+ (setq time-a (apply #'encode-time (parse-time-string (match-string 0 a))))
(string-match tramp-adb-ls-date-regexp b)
- (setq time-b (apply 'encode-time (parse-time-string (match-string 0 b))))
+ (setq time-b (apply #'encode-time (parse-time-string (match-string 0 b))))
(time-less-p time-b time-a)))
(defun tramp-adb-ls-output-name-less-p (a b)
diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el
index 6cc5214..d491dff 100644
--- a/lisp/org/org-agenda.el
+++ b/lisp/org/org-agenda.el
@@ -5491,8 +5491,8 @@ displayed in agenda view."
(substring
(format-time-string
(car org-time-stamp-formats)
- (apply #'encode-time ; DATE bound by calendar
- (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
+ (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]>\\)"
"\\|\\(<%%\\(([^>\n]+)\\)>\\)"))
@@ -5742,8 +5742,8 @@ then those holidays will be skipped."
(substring
(format-time-string
(car org-time-stamp-formats)
- (apply 'encode-time ; DATE bound by calendar
- (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
+ (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)
marker hdmarker priority category level tags closedp
@@ -5860,10 +5860,8 @@ See also the user option
`org-agenda-clock-consistency-checks'."
(throw 'next t))
(setq ts (match-string 1)
te (match-string 3)
- ts (float-time
- (apply #'encode-time (org-parse-time-string ts)))
- te (float-time
- (apply #'encode-time (org-parse-time-string te)))
+ ts (float-time (org-time-string-to-time ts))
+ te (float-time (org-time-string-to-time te))
dt (- te ts))))
(cond
((> dt (* 60 maxtime))
diff --git a/lisp/org/org-capture.el b/lisp/org/org-capture.el
index a699d2e..0c7f159 100644
--- a/lisp/org/org-capture.el
+++ b/lisp/org/org-capture.el
@@ -1009,9 +1009,8 @@ Store them in the capture property list."
(not (= (time-to-days prompt-time) (org-today))))
;; Use 00:00 when no time is given for another
;; date than today?
- (apply #'encode-time
- (append '(0 0 0)
- (cl-cdddr (decode-time prompt-time)))))
+ (apply #'encode-time 0 0 0
+ (cl-cdddr (decode-time prompt-time))))
((string-match "\\([^ ]+\\)--?[^ ]+[ ]+\\(.*\\)"
org-read-date-final-answer)
;; Replace any time range by its start.
diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el
index b177450..babf1f7 100644
--- a/lisp/org/org-clock.el
+++ b/lisp/org/org-clock.el
@@ -723,8 +723,8 @@ menu\nmouse-2 will jump to task"))
The time returned includes the time spent on this task in
previous clocking intervals."
(let ((currently-clocked-time
- (floor (- (float-time)
- (float-time org-clock-start-time)) 60)))
+ (floor (encode-time (time-subtract nil org-clock-start-time) 'integer)
+ 60)))
(+ currently-clocked-time (or org-clock-total-time 0))))
(defun org-clock-modify-effort-estimate (&optional value)
@@ -1033,8 +1033,9 @@ to be CLOCKED OUT."))))
nil 45)))
(and (not (memq char-pressed '(?i ?q))) char-pressed)))))
(default
- (floor (/ (float-time
- (time-subtract (current-time) last-valid)) 60)))
+ (floor (encode-time (time-subtract (current-time) last-valid)
+ 'integer)
+ 60))
(keep
(and (memq ch '(?k ?K))
(read-number "Keep how many minutes? " default)))
@@ -1102,8 +1103,8 @@ If `only-dangling-p' is non-nil, only ask to resolve
dangling
(lambda (clock)
(format
"Dangling clock started %d mins ago"
- (floor (- (float-time)
- (float-time (cdr clock)))
+ (floor (encode-time (time-subtract nil (cdr clock))
+ 'integer)
60)))))
(or last-valid
(cdr clock)))))))))))
@@ -1293,8 +1294,7 @@ the default behavior."
(setq ts (concat "[" (match-string 1) "]"))
(goto-char (match-end 1))
(setq org-clock-start-time
- (apply 'encode-time
- (org-parse-time-string (match-string 1))))
+ (org-time-string-to-time (match-string 1)))
(setq org-clock-effort (org-entry-get (point) org-effort-property))
(setq org-clock-total-time (org-clock-sum-current-item
(org-clock-get-sum-start))))
@@ -1431,7 +1431,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 (append (list 0 0) (nthcdr 2 dt)))))
+ (apply #'encode-time 0 0 (nthcdr 2 dt))))
((or (equal cmt "all")
(and (or (not cmt) (equal cmt "auto"))
(not lr)))
@@ -1577,14 +1577,12 @@ to, overriding the existing value of
`org-clock-out-switch-to-state'."
(delete-region (point) (point-at-eol))
(insert "--")
(setq te (org-insert-time-stamp (or at-time now) 'with-hm 'inactive))
- (setq s (- (float-time
- (apply #'encode-time (org-parse-time-string te)))
- (float-time
- (apply #'encode-time (org-parse-time-string ts))))
- h (floor (/ s 3600))
+ (setq s (float-time (time-subtract
+ (org-time-string-to-time te)
+ (org-time-string-to-time ts)))
+ h (floor s 3600)
s (- s (* 3600 h))
- m (floor (/ s 60))
- s (- s (* 60 s)))
+ m (floor s 60))
(insert " => " (format "%2d:%02d" h m))
(move-marker org-clock-marker nil)
(move-marker org-clock-hd-marker nil)
@@ -1813,15 +1811,15 @@ PROPNAME lets you set a custom text property instead of
:org-clock-minutes."
((match-end 2)
;; Two time stamps.
(let* ((ts (float-time
- (apply #'encode-time
- (save-match-data
- (org-parse-time-string (match-string 2))))))
+ (encode-time
+ (save-match-data
+ (org-parse-time-string (match-string 2))))))
(te (float-time
- (apply #'encode-time
- (org-parse-time-string (match-string 3)))))
+ (encode-time
+ (org-parse-time-string (match-string 3)))))
(dt (- (if tend (min te tend) te)
(if tstart (max ts tstart) ts))))
- (when (> dt 0) (cl-incf t1 (floor (/ dt 60))))))
+ (when (> dt 0) (cl-incf t1 (floor dt 60)))))
((match-end 4)
;; A naked time.
(setq t1 (+ t1 (string-to-number (match-string 5))
@@ -2704,14 +2702,14 @@ LEVEL is an integer. Indent by two spaces per level
above 1."
(pcase-let ((`(,month ,day ,year) (calendar-gregorian-from-absolute ts)))
(setq ts (float-time (encode-time 0 0 0 day month year)))))
(ts
- (setq ts (float-time (apply #'encode-time (org-parse-time-string ts))))))
+ (setq ts (float-time (org-time-string-to-time ts)))))
(cond
((numberp te)
;; Likewise for te.
(pcase-let ((`(,month ,day ,year) (calendar-gregorian-from-absolute te)))
(setq te (float-time (encode-time 0 0 0 day month year)))))
(te
- (setq te (float-time (apply #'encode-time (org-parse-time-string te))))))
+ (setq te (float-time (org-time-string-to-time te)))))
(setq tsb
(if (eq step0 'week)
(let ((dow (nth 6 (decode-time (encode-time ts)))))
@@ -2720,7 +2718,7 @@ LEVEL is an integer. Indent by two spaces per level
above 1."
ts))
(while (< tsb te)
(unless (bolp) (insert "\n"))
- (let ((start-time (encode-time (max tsb ts))))
+ (let ((start-time (max tsb ts)))
(cl-incf tsb (let ((dow (nth 6 (decode-time (encode-time tsb)))))
(if (or (eq step0 'day)
(= dow ws))
@@ -2882,18 +2880,16 @@ Otherwise, return nil."
(<= org-clock-marker (point-at-eol)))
;; The clock is running here
(setq org-clock-start-time
- (apply 'encode-time
- (org-parse-time-string (match-string 1))))
+ (org-time-string-to-time (match-string 1)))
(org-clock-update-mode-line)))
(t
(and (match-end 4) (delete-region (match-beginning 4) (match-end 4)))
(end-of-line 1)
(setq ts (match-string 1)
te (match-string 3))
- (setq s (- (float-time
- (apply #'encode-time (org-parse-time-string te)))
- (float-time
- (apply #'encode-time (org-parse-time-string ts))))
+ (setq s (float-time
+ (time-subtract (org-time-string-to-time te)
+ (org-time-string-to-time ts)))
neg (< s 0)
s (abs s)
h (floor (/ s 3600))
diff --git a/lisp/org/org-colview.el b/lisp/org/org-colview.el
index 2c34edd..f3e118b 100644
--- a/lisp/org/org-colview.el
+++ b/lisp/org/org-colview.el
@@ -719,7 +719,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 (encode-time x)))
(list time-before time time-after)))))
(defun org-columns-open-link (&optional arg)
@@ -1070,7 +1070,7 @@ as a canonical duration, i.e., using units defined in
(cond
((string-match-p org-ts-regexp s)
(/ (- org-columns--time
- (float-time (apply #'encode-time (org-parse-time-string s))))
+ (float-time (org-time-string-to-time s)))
60))
((org-duration-p s) (org-duration-to-minutes s t)) ;skip user units
(t (user-error "Invalid age: %S" s))))
diff --git a/lisp/org/org-macro.el b/lisp/org/org-macro.el
index 7d04d02..a151e1e 100644
--- a/lisp/org/org-macro.el
+++ b/lisp/org/org-macro.el
@@ -313,7 +313,7 @@ Return a list of arguments, as strings. This is the
opposite of
(buffer-substring
(point) (line-end-position)))))
(when (cl-some #'identity time)
- (setq date (apply #'encode-time time))))))))
+ (setq date (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/org-table.el b/lisp/org/org-table.el
index 0a8382c..81a77fd 100644
--- a/lisp/org/org-table.el
+++ b/lisp/org/org-table.el
@@ -2909,8 +2909,8 @@ location of point."
(format-time-string
(org-time-stamp-format
(string-match-p "[0-9]\\{1,2\\}:[0-9]\\{2\\}" ts))
- (apply #'encode-time
- (save-match-data (org-parse-time-string ts))))))
+ (encode-time
+ (save-match-data (org-parse-time-string ts))))))
form t t))
(setq ev (if (and duration (string-match
"^[0-9]+:[0-9]+\\(?::[0-9]+\\)?$" form))
diff --git a/lisp/org/org.el b/lisp/org/org.el
index 91a4799..b627282 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -5613,16 +5613,15 @@ When ROUNDING-MINUTES is not an integer, fall back on
the car of
the rounding returns a past time."
(let ((r (or (and (integerp rounding-minutes) rounding-minutes)
(car org-time-stamp-rounding-minutes)))
- (time (decode-time)) res)
+ (now (current-time)))
(if (< r 1)
- (current-time)
- (setq res
- (apply 'encode-time
- (append (list 0 (* r (floor (+ .5 (/ (float (nth 1 time))
r)))))
- (nthcdr 2 time))))
- (if (and past (< (float-time (time-subtract (current-time) res)) 0))
- (encode-time (- (float-time res) (* r 60)))
- res))))
+ now
+ (let* ((time (decode-time now))
+ (res (apply #'encode-time 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)))))))
(defun org-today ()
"Return today date, considering `org-extend-today-until'."
@@ -9743,9 +9742,7 @@ active region."
(setq link
(format-time-string
(car org-time-stamp-formats)
- (apply 'encode-time
- (list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
- nil nil nil))))
+ (encode-time 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd))))
(org-store-link-props :type "calendar" :date cd)))
((eq major-mode 'help-mode)
@@ -13344,7 +13341,7 @@ for calling org-schedule with, or if there is no
scheduling,
returns nil."
(let ((time (org-entry-get pom "SCHEDULED" inherit)))
(when time
- (apply 'encode-time (org-parse-time-string time)))))
+ (org-time-string-to-time time))))
(defun org-get-deadline-time (pom &optional inherit)
"Get the deadline as a time tuple, of a format suitable for
@@ -13352,7 +13349,7 @@ calling org-deadline with, or if there is no
scheduling, returns
nil."
(let ((time (org-entry-get pom "DEADLINE" inherit)))
(when time
- (apply 'encode-time (org-parse-time-string time)))))
+ (org-time-string-to-time time))))
(defun org-remove-timestamp-with-keyword (keyword)
"Remove all time stamps with KEYWORD in the current entry."
@@ -13411,7 +13408,7 @@ WHAT entry will also be removed."
org-deadline-time-regexp)
end t)
(setq ts (match-string 1)
- default-time (apply 'encode-time (org-parse-time-string ts))
+ default-time (org-time-string-to-time ts)
default-input (and ts (org-get-compact-tod ts)))))))
(when what
(setq time
@@ -14668,7 +14665,7 @@ it as a time string and apply `float-time' to it. If S
is nil, just return 0."
((numberp s) s)
((stringp s)
(condition-case nil
- (float-time (apply #'encode-time (org-parse-time-string s)))
+ (float-time (org-time-string-to-time s))
(error 0.)))
(t 0.)))
@@ -14676,8 +14673,7 @@ it as a time string and apply `float-time' to it. If S
is nil, just return 0."
"Time in seconds today at 0:00.
Returns the float number of seconds since the beginning of the
epoch to the beginning of today (00:00)."
- (float-time (apply 'encode-time
- (append '(0 0 0) (nthcdr 3 (decode-time))))))
+ (float-time (apply #'encode-time 0 0 0 (nthcdr 3 (decode-time)))))
(defun org-matcher-time (s)
"Interpret a time comparison value."
@@ -16573,7 +16569,7 @@ non-nil."
;; Default time is either the timestamp at point or today.
;; When entering a range, only the range start is considered.
(default-time (if (not ts) (current-time)
- (apply #'encode-time (org-parse-time-string ts))))
+ (org-time-string-to-time ts)))
(default-input (and ts (org-get-compact-tod ts)))
(repeater (and ts
(string-match "\\([.+-]+[0-9]+[hdwmy] ?\\)+" ts)
@@ -16820,7 +16816,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 (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")
@@ -16893,13 +16889,14 @@ user."
"range representable on this machine"))
(ding))
- ;; One round trip to get rid of 34th of August and stuff like that....
- (setq final (decode-time (apply 'encode-time final)))
+ (setq final (apply #'encode-time final))
(setq org-read-date-final-answer ans)
(if to-time
- (apply 'encode-time final)
+ final
+ ;; This round-trip gets rid of 34th of August and stuff like that....
+ (setq final (decode-time final))
(if (and (boundp 'org-time-was-given) org-time-was-given)
(format "%04d-%02d-%02d %02d:%02d"
(nth 5 final) (nth 4 final) (nth 3 final)
@@ -16929,7 +16926,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 (apply #'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
@@ -17296,7 +17293,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) (encode-time time))
nil 'mouse-face 'highlight))
(put-text-property beg end 'display str)))
@@ -17553,7 +17550,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)))
+ (encode-time (org-parse-time-string s)))
(defun org-time-string-to-seconds (s)
"Convert a timestamp string S into a number of seconds."
@@ -17588,7 +17585,7 @@ signaled."
(daynr (org-closest-date s daynr prefer))
(t (time-to-days
(condition-case errdata
- (apply #'encode-time (org-parse-time-string s))
+ (org-time-string-to-time s)
(error (error "Bad timestamp `%s'%s\nError was: %s"
s
(if (not (and buffer pos)) ""
@@ -17686,12 +17683,12 @@ stamp stay unchanged. In any case, return value is
an absolute
day number."
(if (not (string-match "\\+\\([0-9]+\\)\\([hdwmy]\\)" start))
;; No repeater. Do not shift time stamp.
- (time-to-days (apply #'encode-time (org-parse-time-string start)))
+ (time-to-days (org-time-string-to-time start))
(let ((value (string-to-number (match-string 1 start)))
(type (match-string 2 start)))
(if (= 0 value)
;; Repeater with a 0-value is considered as void.
- (time-to-days (apply #'encode-time (org-parse-time-string start)))
+ (time-to-days (org-time-string-to-time start))
(let* ((base (org-date-to-gregorian start))
(target (org-date-to-gregorian current))
(sday (calendar-absolute-from-gregorian base))
@@ -18000,7 +17997,7 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays
like \"--2d\"."
(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 (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).
@@ -23389,13 +23386,12 @@ strictly within a source block, use appropriate
comment syntax."
(defun org-timestamp--to-internal-time (timestamp &optional end)
"Encode TIMESTAMP object into Emacs internal time.
Use end of date range or time range when END is non-nil."
- (apply #'encode-time
- (cons 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))))))
+ (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)))))
(defun org-timestamp-has-time-p (timestamp)
"Non-nil when TIMESTAMP has a time specified."
diff --git a/lisp/url/url-dav.el b/lisp/url/url-dav.el
index 2cc2b18..a4cf0f0 100644
--- a/lisp/url/url-dav.el
+++ b/lisp/url/url-dav.el
@@ -146,7 +146,7 @@ Returns nil if WebDAV is not supported."
(setq time (parse-time-string date-string)))
(if time
- (setq time (apply 'encode-time time))
+ (setq time (encode-time time))
(url-debug 'dav "Unable to decode date (%S) (%s)"
(xml-node-name node) date-string))
time))
diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el
index 5df0a28..a4ff1cb 100644
--- a/lisp/vc/vc-cvs.el
+++ b/lisp/vc/vc-cvs.el
@@ -650,7 +650,7 @@ Optional arg REVISION is a revision to annotate from."
"Return the current time, based at midnight of the current day, and
encoded as fractional days."
(vc-annotate-convert-time
- (apply 'encode-time 0 0 0 (nthcdr 3 (decode-time)))))
+ (apply #'encode-time 0 0 0 (nthcdr 3 (decode-time)))))
(defun vc-cvs-annotate-time ()
"Return the time of the next annotation (as fraction of days)
@@ -1184,9 +1184,8 @@ is non-nil."
(car parsed-time)
;; Compare just the seconds part of the file time,
;; since CVS file time stamp resolution is just 1 second.
- (let ((ptime (apply 'encode-time parsed-time)))
- (and (eq (car mtime) (car ptime))
- (eq (cadr mtime) (cadr ptime)))))
+ (= (encode-time mtime 'integer)
+ (encode-time parsed-time 'integer)))
(vc-file-setprop file 'vc-checkout-time mtime)
(if set-state (vc-file-setprop file 'vc-state 'up-to-date)))
(t