]> git.eshelyaron.com Git - emacs.git/commitdiff
Use decoded time accessors in Gnus
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 30 Jul 2019 11:05:17 +0000 (13:05 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 30 Jul 2019 11:05:17 +0000 (13:05 +0200)
* lisp/gnus/nnimap.el (nnimap-find-expired-articles):
* lisp/gnus/nndiary.el (nndiary-compute-reminders)
(nndiary-last-occurrence, nndiary-next-occurrence):
* lisp/gnus/message.el (message-make-expires-date):
* lisp/gnus/gnus-util.el (gnus-seconds-today)
(gnus-seconds-month, gnus-seconds-year):
* lisp/gnus/gnus-demon.el (gnus-demon-time-to-step):
* lisp/gnus/gnus-art.el (article-make-date-line): Use decoded time
accessors.

lisp/gnus/gnus-art.el
lisp/gnus/gnus-demon.el
lisp/gnus/gnus-util.el
lisp/gnus/message.el
lisp/gnus/nndiary.el
lisp/gnus/nnimap.el

index 89f57712c565668bc2d13dedc084931d3fc22c06..a38300ef66a27d63d77e37922ed97e71ce2b4950 100644 (file)
@@ -3598,22 +3598,22 @@ possible values."
          (let ((dtime (decode-time time)))
            (concat
             "Date: the "
-            (number-to-string (nth 3 dtime))
-            (let ((digit (% (nth 3 dtime) 10)))
+            (number-to-string (decoded-time-day dtime))
+            (let ((digit (% (decoded-time-day dtime) 10)))
               (cond
-               ((memq (nth 3 dtime) '(11 12 13)) "th")
+               ((memq (decoded-time-day dtime) '(11 12 13)) "th")
                ((= digit 1) "st")
                ((= digit 2) "nd")
                ((= digit 3) "rd")
                (t "th")))
             " of "
-            (nth (1- (nth 4 dtime)) gnus-english-month-names)
+            (nth (1- (decoded-time-month dtime)) gnus-english-month-names)
             " "
-            (number-to-string (nth 5 dtime))
+            (number-to-string (decoded-time-year dtime))
             " at "
-            (format "%02d" (nth 2 dtime))
+            (format "%02d" (decoded-time-hour dtime))
             ":"
-            (format "%02d" (nth 1 dtime)))))))
+            (format "%02d" (decoded-time-minute dtime)))))))
     (foo
      (format "Date: %s (from Gnus)" date))))
 
index cb70d9525c296e257a6a6dcea26be725a5972af3..b26aaa1529734dded63d1ef6309f1d1e8fa4551d 100644 (file)
@@ -176,22 +176,25 @@ marked with SPECIAL."
         (thenHour (elt thenParts 2))
         (thenMin (elt thenParts 1))
         ;; convert time as elements into number of seconds since EPOCH.
-        (then (encode-time 0
-                           thenMin
-                           thenHour
-                           ;; If THEN is earlier than NOW, make it
-                           ;; same time tomorrow.  Doc for encode-time
-                           ;; says that this is OK.
-                           (+ (elt nowParts 3)
-                              (if (or (< thenHour (elt nowParts 2))
-                                      (and (= thenHour (elt nowParts 2))
-                                           (<= thenMin (elt nowParts 1))))
-                                  1 0))
-                           (elt nowParts 4)
-                           (elt nowParts 5)
-                           (elt nowParts 6)
-                           (elt nowParts 7)
-                           (elt nowParts 8)))
+        (then (encode-time
+               0
+               thenMin
+               thenHour
+               ;; If THEN is earlier than NOW, make it
+               ;; same time tomorrow.  Doc for encode-time
+               ;; says that this is OK.
+               (+ (decoded-time-day nowParts)
+                  (if (or (< thenHour (decoded-time-hour nowParts))
+                          (and (= thenHour
+                                  (decoded-time-hour nowParts))
+                               (<= thenMin
+                                   (decoded-time-minute nowParts))))
+                      1 0))
+               (decoded-time-month nowParts)
+               (decoded-time-year nowParts)
+               (decoded-time-weekday nowParts)
+               (decoded-time-dst nowParts)
+               (decoded-time-zone nowParts)))
         (diff (float-time (time-subtract then now))))
     ;; Return number of timesteps in the number of seconds.
     (round diff gnus-demon-timestep)))
index 31421cc755540fb6678a54ecb4718863cd8547ef..9ccdb83865ca69e8978fbd3fe62b3ad20a989a1f 100644 (file)
@@ -359,20 +359,26 @@ Symbols are also allowed; their print names are used instead."
 (defun gnus-seconds-today ()
   "Return the number of seconds passed today."
   (let ((now (decode-time)))
-    (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600))))
+    (+ (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)))
-    (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600)
-       (* (- (car (nthcdr 3 now)) 1) 3600 24))))
+    (+ (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."
   (let* ((current (current-time))
         (now (decode-time current))
         (days (format-time-string "%j" current)))
-    (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600)
+    (+ (decoded-time-second now)
+       (* (decoded-time-minute now) 60)
+       (* (decoded-time-hour now) 3600)
        (* (- (string-to-number days) 1) 3600 24))))
 
 (defmacro gnus-date-get-time (date)
index 3f190ed6517648d3b6daa0981c8e6ca9513cad6e..ea7a282b8ba1c696e804f80cf70624e0510f93d2 100644 (file)
@@ -5509,8 +5509,8 @@ If NOW, use that time instead."
 
 In posting styles use `(\"Expires\" (make-expires-date 30))'."
   (let* ((cur (decode-time))
-        (nday (+ days (nth 3 cur))))
-    (setf (nth 3 cur) nday)
+        (nday (+ days (decoded-time-day cur))))
+    (setf (decoded-time-day cur) nday)
     (message-make-date (encode-time cur))))
 
 (defun message-make-message-id ()
index f8ec222616f5c8e0158e967db0b7085c5fbe6507..2ad0634e6adf9620f81867260652da80dcda71fe 100644 (file)
@@ -1264,12 +1264,12 @@ all.  This may very well take some time.")
         (date-elts (decode-time date))
         ;; ### NOTE: out-of-range values are accepted by encode-time. This
         ;; makes our life easier.
-        (monday (- (nth 3 date-elts)
+        (monday (- (decoded-time-day date-elts)
                    (if nndiary-week-starts-on-monday
-                       (if (zerop (nth 6 date-elts))
+                       (if (zerop (decoded-time-weekday date-elts))
                            6
-                         (- (nth 6 date-elts) 1))
-                     (nth 6 date-elts))))
+                         (- (decoded-time-weekday date-elts) 1))
+                     (decoded-time-weekday date-elts))))
         reminder res)
     ;; remove the DOW and DST entries
     (setcdr (nthcdr 5 date-elts) (nthcdr 8 date-elts))
@@ -1343,9 +1343,10 @@ all.  This may very well take some time.")
                 ;; have to know which day is the 1st one for this month.
                 ;; Maybe there's simpler, but decode-time(encode-time) will
                 ;; give us the answer.
-                (let ((first (nth 6 (decode-time
-                                     (encode-time 0 0 0 1 month year
-                                                  time-zone))))
+                (let ((first (decoded-time-weekday
+                              (decode-time
+                               (encode-time 0 0 0 1 month year
+                                            time-zone))))
                       (max (cond ((= month 2)
                                   (if (date-leap-year-p year) 29 28))
                                  ((<= month 7)
@@ -1390,11 +1391,11 @@ all.  This may very well take some time.")
   ;; If there's no next occurrence, returns the last one (if any) which is then
   ;; in the past.
   (let* ((today (decode-time now))
-        (this-minute (nth 1 today))
-        (this-hour (nth 2 today))
-        (this-day (nth 3 today))
-        (this-month (nth 4 today))
-        (this-year (nth 5 today))
+        (this-minute (decoded-time-minute today))
+        (this-hour (decoded-time-hour today))
+        (this-day (decoded-time-day today))
+        (this-month (decoded-time-month today))
+        (this-year (decoded-time-year today))
         (minute-list (sort (nndiary-flatten (nth 0 sched) 0 59) '<))
         (hour-list (sort (nndiary-flatten (nth 1 sched) 0 23) '<))
         (dom-list (nth 2 sched))
@@ -1445,9 +1446,10 @@ all.  This may very well take some time.")
                 ;; have to know which day is the 1st one for this month.
                 ;; Maybe there's simpler, but decode-time(encode-time) will
                 ;; give us the answer.
-                (let ((first (nth 6 (decode-time
-                                     (encode-time 0 0 0 1 month year
-                                                  time-zone))))
+                (let ((first (decoded-time-weekday
+                              (decode-time
+                               (encode-time 0 0 0 1 month year
+                                            time-zone))))
                       (max (cond ((= month 2)
                                   (if (date-leap-year-p year) 29 28))
                                  ((<= month 7)
index 99a610487fe76e9f9bc166766b31f64a7abe2709..c6eaa54c692fcb679a6f10904d6ac9ee65af73a3 100644 (file)
@@ -1100,7 +1100,7 @@ textual parts.")
                (format-time-string
                 (format "%%d-%s-%%Y"
                         (upcase
-                         (car (rassoc (nth 4 (decode-time cutoff))
+                         (car (rassoc (decoded-time-month (decode-time cutoff))
                                       parse-time-months))))
                 cutoff))))
          (and (car result)