emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c90a420: Add FIXMEs for subsecond support


From: Paul Eggert
Subject: [Emacs-diffs] master c90a420: Add FIXMEs for subsecond support
Date: Sat, 17 Aug 2019 18:43:10 -0400 (EDT)

branch: master
commit c90a420779448fecf1941f063da3e8276dc3d0d7
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    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.
---
 lisp/calc/calc-forms.el    |  8 +++++---
 lisp/calendar/icalendar.el |  9 +++++++--
 lisp/calendar/iso8601.el   |  3 ++-
 lisp/gnus/gnus-delay.el    |  2 +-
 lisp/gnus/gnus-util.el     | 12 ++++++------
 lisp/gnus/message.el       |  2 +-
 lisp/midnight.el           |  4 ++--
 lisp/org/org-timer.el      |  3 ++-
 lisp/vc/ediff-mult.el      |  3 ++-
 9 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/lisp/calc/calc-forms.el b/lisp/calc/calc-forms.el
index c410ffe..7e8a8dc 100644
--- a/lisp/calc/calc-forms.el
+++ b/lisp/calc/calc-forms.el
@@ -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)
diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el
index c268870..3c46982 100644
--- a/lisp/calendar/icalendar.el
+++ b/lisp/calendar/icalendar.el
@@ -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))
diff --git a/lisp/calendar/iso8601.el b/lisp/calendar/iso8601.el
index 30352c7..0f42c82 100644
--- a/lisp/calendar/iso8601.el
+++ b/lisp/calendar/iso8601.el
@@ -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))
diff --git a/lisp/gnus/gnus-delay.el b/lisp/gnus/gnus-delay.el
index aabf239..512011f 100644
--- a/lisp/gnus/gnus-delay.el
+++ b/lisp/gnus/gnus-delay.el
@@ -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)))
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index c6be59f..f73af8e 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -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)
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 0a540a6..48d7910 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -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))))
diff --git a/lisp/midnight.el b/lisp/midnight.el
index fa41d80..aad5236 100644
--- a/lisp/midnight.el
+++ b/lisp/midnight.el
@@ -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
diff --git a/lisp/org/org-timer.el b/lisp/org/org-timer.el
index 6529a8b0..20b33a1 100644
--- a/lisp/org/org-timer.el
+++ b/lisp/org/org-timer.el
@@ -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"
diff --git a/lisp/vc/ediff-mult.el b/lisp/vc/ediff-mult.el
index 1bdaca2..66d14e6 100644
--- a/lisp/vc/ediff-mult.el
+++ b/lisp/vc/ediff-mult.el
@@ -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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]