Commit c90a4207 authored by Paul Eggert's avatar Paul Eggert

Add FIXMEs for subsecond support

This adds FIXMEs to areas where Lisp code should support
subsecond information in broken-down timestamps.
It also fixes some unnecessary truncation of timestamps, and
ports the code to a hypothetical future Emacs version where
(decode-time) returns subsecond timestamps by default.
* lisp/calc/calc-forms.el (calc-time, math-iso-dt-to-date)
(calcFunc-now):
* lisp/calendar/icalendar.el (icalendar--add-decoded-times):
* lisp/calendar/iso8601.el (iso8601-parse-interval):
Truncate seconds to an integer, and add a FIXME about
subseconds support.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime)
(icalendar--decode-isoduration):
Add a FIXME about subseconds support.
* lisp/gnus/gnus-delay.el (gnus-delay-article):
Don’t truncate seconds to an integer, as there’s no need
to do that here.
* lisp/gnus/gnus-util.el (gnus-seconds-today)
(gnus-seconds-month, gnus-seconds-year):
* lisp/gnus/message.el (message-make-expires-date):
* lisp/org/org-timer.el (org-timer-show-remaining-time):
* lisp/vc/ediff-mult.el (ediff-format-date):
Truncate seconds to an integer, as that’s what’s wanted here.
* lisp/midnight.el (midnight-next):
Ceiling seconds to an integer, as that’s what wanted here.
parent 66168068
Pipeline #2879 failed with stage
in 58 minutes and 56 seconds
......@@ -37,7 +37,7 @@
(defun calc-time ()
(interactive)
(calc-wrapper
(let ((time (decode-time)))
(let ((time (decode-time nil nil 'integer))) ;; FIXME: Support subseconds.
(calc-enter-result 0 "time"
(list 'mod
(list 'hms
......@@ -499,7 +499,8 @@ in the Gregorian calendar and the remaining part determines the time."
(math-add (math-float date)
(math-div (math-add (+ (* (nth 3 dt) 3600)
(* (nth 4 dt) 60))
(nth 5 dt))
;; FIXME: Support subseconds.
(time-convert (nth 5 dt) 'integer))
'(float 864 2)))
date)))
......@@ -1327,7 +1328,8 @@ as measured in the integer number of days before December 31, 1 BC (Gregorian)."
(math-parse-iso-date-validate isoyear isoweek isoweekday hour minute second)))))
(defun calcFunc-now (&optional zone)
(let ((date (let ((now (decode-time)))
;; FIXME: Support subseconds.
(let ((date (let ((now (decode-time nil nil 'integer)))
(list 'date (math-dt-to-date
(list (decoded-time-year now)
(decoded-time-month now)
......
......@@ -628,6 +628,7 @@ FIXME: multiple comma-separated values should be allowed!"
(when (> (length isodatetimestring) 14)
;; seconds present
(setq second (read (substring isodatetimestring 13 15))))
;; FIXME: Support subseconds.
(when (and (> (length isodatetimestring) 15)
;; UTC specifier present
(char-equal ?Z (aref isodatetimestring 15)))
......@@ -703,6 +704,7 @@ FIXME: multiple comma-separated values should be allowed!"
(setq minutes (read (substring isodurationstring
(match-beginning 10)
(match-end 10)))))
;; FIXME: Support subseconds.
(if (match-beginning 11)
(setq seconds (read (substring isodurationstring
(match-beginning 12)
......@@ -719,9 +721,12 @@ FIXME: multiple comma-separated values should be allowed!"
"Add TIME1 to TIME2.
Both times must be given in decoded form. One of these times must be
valid (year > 1900 or something)."
;; FIXME: does this function exist already?
;; FIXME: does this function exist already? Can we use decoded-time-add?
(decode-time (encode-time
(+ (decoded-time-second time1) (decoded-time-second time2))
;; FIXME: Support subseconds.
(time-convert (time-add (decoded-time-second time1)
(decoded-time-second time2))
'integer)
(+ (decoded-time-minute time1) (decoded-time-minute time2))
(+ (decoded-time-hour time1) (decoded-time-hour time2))
(+ (decoded-time-day time1) (decoded-time-day time2))
......
......@@ -322,9 +322,10 @@ Return the number of minutes."
duration))))
(list start end
(or duration
;; FIXME: Support subseconds.
(decode-time (time-subtract (iso8601--encode-time end)
(iso8601--encode-time start))
(or (decoded-time-zone end) 0))))))
(or (decoded-time-zone end) 0) 'integer)))))
(defun iso8601--match (regexp string)
(string-match (concat "\\`" regexp "\\'") string))
......
......@@ -98,7 +98,7 @@ 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 (decode-time))
(setq deadline (decode-time nil nil t))
;; ... for minute and hour.
(setq deadline (apply #'encode-time (car deadline) minute hour
(nthcdr 3 deadline)))
......
......@@ -357,24 +357,24 @@ Symbols are also allowed; their print names are used instead."
;; the full date if it's older)
(defun gnus-seconds-today ()
"Return the number of seconds passed today."
(let ((now (decode-time)))
"Return the integer number of seconds passed today."
(let ((now (decode-time nil nil 'integer)))
(+ (decoded-time-second now)
(* (decoded-time-minute now) 60)
(* (decoded-time-hour now) 3600))))
(defun gnus-seconds-month ()
"Return the number of seconds passed this month."
(let ((now (decode-time)))
"Return the integer number of seconds passed this month."
(let ((now (decode-time nil nil 'integer)))
(+ (decoded-time-second now)
(* (decoded-time-minute now) 60)
(* (decoded-time-hour now) 3600)
(* (- (decoded-time-day now) 1) 3600 24))))
(defun gnus-seconds-year ()
"Return the number of seconds passed this year."
"Return the integer number of seconds passed this year."
(let* ((current (current-time))
(now (decode-time current))
(now (decode-time current nil 'integer))
(days (format-time-string "%j" current)))
(+ (decoded-time-second now)
(* (decoded-time-minute now) 60)
......
......@@ -5508,7 +5508,7 @@ If NOW, use that time instead."
"Make date string for the Expires header. Expiry in DAYS days.
In posting styles use `(\"Expires\" (make-expires-date 30))'."
(let* ((cur (decode-time))
(let* ((cur (decode-time nil nil 'integer))
(nday (+ days (decoded-time-day cur))))
(setf (decoded-time-day cur) nday)
(message-make-date (encode-time cur))))
......
......@@ -193,8 +193,8 @@ The default value is `clean-buffer-list'."
:type 'hook)
(defun midnight-next ()
"Return the number of seconds till the next midnight."
(pcase-let ((`(,sec ,min ,hrs) (decode-time)))
"Return the number of whole or partial seconds till the next midnight."
(pcase-let ((`(,sec ,min ,hrs) (decode-time nil nil 'integer)))
(- (* 24 60 60) (* 60 60 hrs) (* 60 min) sec)))
;;;###autoload
......
......@@ -385,7 +385,8 @@ VALUE can be `on', `off', or `paused'."
(message "No timer set")
(let* ((rtime (decode-time
(time-subtract (timer--time org-timer-countdown-timer)
nil)))
nil)
'integer))
(rsecs (nth 0 rtime))
(rmins (nth 1 rtime)))
(message "%d minute(s) %d seconds left before next time out"
......
......@@ -1210,7 +1210,8 @@ behavior."
(decoded-time-year time)
(ediff-fill-leading-zero (decoded-time-hour time))
(ediff-fill-leading-zero (decoded-time-minute time))
(ediff-fill-leading-zero (decoded-time-second time))))
(ediff-fill-leading-zero (time-convert (decoded-time-second time)
'integer))))
;; Draw the directories
(defun ediff-insert-dirs-in-meta-buffer (meta-list)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment