aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-07-30 13:05:17 +0200
committerLars Ingebrigtsen2019-07-30 13:05:17 +0200
commitbd26eff54779bfd5739c1d663bcabd19246682d8 (patch)
treeb362161824f4959630f7fc10690f81d23401aed1
parent608832acc35420fc7140f73cd8e18f1a00f93ec6 (diff)
downloademacs-bd26eff54779bfd5739c1d663bcabd19246682d8.tar.gz
emacs-bd26eff54779bfd5739c1d663bcabd19246682d8.zip
Use decoded time accessors in Gnus
* 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.
-rw-r--r--lisp/gnus/gnus-art.el14
-rw-r--r--lisp/gnus/gnus-demon.el35
-rw-r--r--lisp/gnus/gnus-util.el14
-rw-r--r--lisp/gnus/message.el4
-rw-r--r--lisp/gnus/nndiary.el32
-rw-r--r--lisp/gnus/nnimap.el2
6 files changed, 56 insertions, 45 deletions
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 89f57712c56..a38300ef66a 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -3598,22 +3598,22 @@ possible values."
3598 (let ((dtime (decode-time time))) 3598 (let ((dtime (decode-time time)))
3599 (concat 3599 (concat
3600 "Date: the " 3600 "Date: the "
3601 (number-to-string (nth 3 dtime)) 3601 (number-to-string (decoded-time-day dtime))
3602 (let ((digit (% (nth 3 dtime) 10))) 3602 (let ((digit (% (decoded-time-day dtime) 10)))
3603 (cond 3603 (cond
3604 ((memq (nth 3 dtime) '(11 12 13)) "th") 3604 ((memq (decoded-time-day dtime) '(11 12 13)) "th")
3605 ((= digit 1) "st") 3605 ((= digit 1) "st")
3606 ((= digit 2) "nd") 3606 ((= digit 2) "nd")
3607 ((= digit 3) "rd") 3607 ((= digit 3) "rd")
3608 (t "th"))) 3608 (t "th")))
3609 " of " 3609 " of "
3610 (nth (1- (nth 4 dtime)) gnus-english-month-names) 3610 (nth (1- (decoded-time-month dtime)) gnus-english-month-names)
3611 " " 3611 " "
3612 (number-to-string (nth 5 dtime)) 3612 (number-to-string (decoded-time-year dtime))
3613 " at " 3613 " at "
3614 (format "%02d" (nth 2 dtime)) 3614 (format "%02d" (decoded-time-hour dtime))
3615 ":" 3615 ":"
3616 (format "%02d" (nth 1 dtime))))))) 3616 (format "%02d" (decoded-time-minute dtime)))))))
3617 (foo 3617 (foo
3618 (format "Date: %s (from Gnus)" date)))) 3618 (format "Date: %s (from Gnus)" date))))
3619 3619
diff --git a/lisp/gnus/gnus-demon.el b/lisp/gnus/gnus-demon.el
index cb70d9525c2..b26aaa15297 100644
--- a/lisp/gnus/gnus-demon.el
+++ b/lisp/gnus/gnus-demon.el
@@ -176,22 +176,25 @@ marked with SPECIAL."
176 (thenHour (elt thenParts 2)) 176 (thenHour (elt thenParts 2))
177 (thenMin (elt thenParts 1)) 177 (thenMin (elt thenParts 1))
178 ;; convert time as elements into number of seconds since EPOCH. 178 ;; convert time as elements into number of seconds since EPOCH.
179 (then (encode-time 0 179 (then (encode-time
180 thenMin 180 0
181 thenHour 181 thenMin
182 ;; If THEN is earlier than NOW, make it 182 thenHour
183 ;; same time tomorrow. Doc for encode-time 183 ;; If THEN is earlier than NOW, make it
184 ;; says that this is OK. 184 ;; same time tomorrow. Doc for encode-time
185 (+ (elt nowParts 3) 185 ;; says that this is OK.
186 (if (or (< thenHour (elt nowParts 2)) 186 (+ (decoded-time-day nowParts)
187 (and (= thenHour (elt nowParts 2)) 187 (if (or (< thenHour (decoded-time-hour nowParts))
188 (<= thenMin (elt nowParts 1)))) 188 (and (= thenHour
189 1 0)) 189 (decoded-time-hour nowParts))
190 (elt nowParts 4) 190 (<= thenMin
191 (elt nowParts 5) 191 (decoded-time-minute nowParts))))
192 (elt nowParts 6) 192 1 0))
193 (elt nowParts 7) 193 (decoded-time-month nowParts)
194 (elt nowParts 8))) 194 (decoded-time-year nowParts)
195 (decoded-time-weekday nowParts)
196 (decoded-time-dst nowParts)
197 (decoded-time-zone nowParts)))
195 (diff (float-time (time-subtract then now)))) 198 (diff (float-time (time-subtract then now))))
196 ;; Return number of timesteps in the number of seconds. 199 ;; Return number of timesteps in the number of seconds.
197 (round diff gnus-demon-timestep))) 200 (round diff gnus-demon-timestep)))
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index 31421cc7555..9ccdb83865c 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -359,20 +359,26 @@ Symbols are also allowed; their print names are used instead."
359(defun gnus-seconds-today () 359(defun gnus-seconds-today ()
360 "Return the number of seconds passed today." 360 "Return the number of seconds passed today."
361 (let ((now (decode-time))) 361 (let ((now (decode-time)))
362 (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600)))) 362 (+ (decoded-time-second now)
363 (* (decoded-time-minute now) 60)
364 (* (decoded-time-hour now) 3600))))
363 365
364(defun gnus-seconds-month () 366(defun gnus-seconds-month ()
365 "Return the number of seconds passed this month." 367 "Return the number of seconds passed this month."
366 (let ((now (decode-time))) 368 (let ((now (decode-time)))
367 (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600) 369 (+ (decoded-time-second now)
368 (* (- (car (nthcdr 3 now)) 1) 3600 24)))) 370 (* (decoded-time-minute now) 60)
371 (* (decoded-time-hour now) 3600)
372 (* (- (decoded-time-day now) 1) 3600 24))))
369 373
370(defun gnus-seconds-year () 374(defun gnus-seconds-year ()
371 "Return the number of seconds passed this year." 375 "Return the number of seconds passed this year."
372 (let* ((current (current-time)) 376 (let* ((current (current-time))
373 (now (decode-time current)) 377 (now (decode-time current))
374 (days (format-time-string "%j" current))) 378 (days (format-time-string "%j" current)))
375 (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600) 379 (+ (decoded-time-second now)
380 (* (decoded-time-minute now) 60)
381 (* (decoded-time-hour now) 3600)
376 (* (- (string-to-number days) 1) 3600 24)))) 382 (* (- (string-to-number days) 1) 3600 24))))
377 383
378(defmacro gnus-date-get-time (date) 384(defmacro gnus-date-get-time (date)
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 3f190ed6517..ea7a282b8ba 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -5509,8 +5509,8 @@ If NOW, use that time instead."
5509 5509
5510In posting styles use `(\"Expires\" (make-expires-date 30))'." 5510In posting styles use `(\"Expires\" (make-expires-date 30))'."
5511 (let* ((cur (decode-time)) 5511 (let* ((cur (decode-time))
5512 (nday (+ days (nth 3 cur)))) 5512 (nday (+ days (decoded-time-day cur))))
5513 (setf (nth 3 cur) nday) 5513 (setf (decoded-time-day cur) nday)
5514 (message-make-date (encode-time cur)))) 5514 (message-make-date (encode-time cur))))
5515 5515
5516(defun message-make-message-id () 5516(defun message-make-message-id ()
diff --git a/lisp/gnus/nndiary.el b/lisp/gnus/nndiary.el
index f8ec222616f..2ad0634e6ad 100644
--- a/lisp/gnus/nndiary.el
+++ b/lisp/gnus/nndiary.el
@@ -1264,12 +1264,12 @@ all. This may very well take some time.")
1264 (date-elts (decode-time date)) 1264 (date-elts (decode-time date))
1265 ;; ### NOTE: out-of-range values are accepted by encode-time. This 1265 ;; ### NOTE: out-of-range values are accepted by encode-time. This
1266 ;; makes our life easier. 1266 ;; makes our life easier.
1267 (monday (- (nth 3 date-elts) 1267 (monday (- (decoded-time-day date-elts)
1268 (if nndiary-week-starts-on-monday 1268 (if nndiary-week-starts-on-monday
1269 (if (zerop (nth 6 date-elts)) 1269 (if (zerop (decoded-time-weekday date-elts))
1270 6 1270 6
1271 (- (nth 6 date-elts) 1)) 1271 (- (decoded-time-weekday date-elts) 1))
1272 (nth 6 date-elts)))) 1272 (decoded-time-weekday date-elts))))
1273 reminder res) 1273 reminder res)
1274 ;; remove the DOW and DST entries 1274 ;; remove the DOW and DST entries
1275 (setcdr (nthcdr 5 date-elts) (nthcdr 8 date-elts)) 1275 (setcdr (nthcdr 5 date-elts) (nthcdr 8 date-elts))
@@ -1343,9 +1343,10 @@ all. This may very well take some time.")
1343 ;; have to know which day is the 1st one for this month. 1343 ;; have to know which day is the 1st one for this month.
1344 ;; Maybe there's simpler, but decode-time(encode-time) will 1344 ;; Maybe there's simpler, but decode-time(encode-time) will
1345 ;; give us the answer. 1345 ;; give us the answer.
1346 (let ((first (nth 6 (decode-time 1346 (let ((first (decoded-time-weekday
1347 (encode-time 0 0 0 1 month year 1347 (decode-time
1348 time-zone)))) 1348 (encode-time 0 0 0 1 month year
1349 time-zone))))
1349 (max (cond ((= month 2) 1350 (max (cond ((= month 2)
1350 (if (date-leap-year-p year) 29 28)) 1351 (if (date-leap-year-p year) 29 28))
1351 ((<= month 7) 1352 ((<= month 7)
@@ -1390,11 +1391,11 @@ all. This may very well take some time.")
1390 ;; If there's no next occurrence, returns the last one (if any) which is then 1391 ;; If there's no next occurrence, returns the last one (if any) which is then
1391 ;; in the past. 1392 ;; in the past.
1392 (let* ((today (decode-time now)) 1393 (let* ((today (decode-time now))
1393 (this-minute (nth 1 today)) 1394 (this-minute (decoded-time-minute today))
1394 (this-hour (nth 2 today)) 1395 (this-hour (decoded-time-hour today))
1395 (this-day (nth 3 today)) 1396 (this-day (decoded-time-day today))
1396 (this-month (nth 4 today)) 1397 (this-month (decoded-time-month today))
1397 (this-year (nth 5 today)) 1398 (this-year (decoded-time-year today))
1398 (minute-list (sort (nndiary-flatten (nth 0 sched) 0 59) '<)) 1399 (minute-list (sort (nndiary-flatten (nth 0 sched) 0 59) '<))
1399 (hour-list (sort (nndiary-flatten (nth 1 sched) 0 23) '<)) 1400 (hour-list (sort (nndiary-flatten (nth 1 sched) 0 23) '<))
1400 (dom-list (nth 2 sched)) 1401 (dom-list (nth 2 sched))
@@ -1445,9 +1446,10 @@ all. This may very well take some time.")
1445 ;; have to know which day is the 1st one for this month. 1446 ;; have to know which day is the 1st one for this month.
1446 ;; Maybe there's simpler, but decode-time(encode-time) will 1447 ;; Maybe there's simpler, but decode-time(encode-time) will
1447 ;; give us the answer. 1448 ;; give us the answer.
1448 (let ((first (nth 6 (decode-time 1449 (let ((first (decoded-time-weekday
1449 (encode-time 0 0 0 1 month year 1450 (decode-time
1450 time-zone)))) 1451 (encode-time 0 0 0 1 month year
1452 time-zone))))
1451 (max (cond ((= month 2) 1453 (max (cond ((= month 2)
1452 (if (date-leap-year-p year) 29 28)) 1454 (if (date-leap-year-p year) 29 28))
1453 ((<= month 7) 1455 ((<= month 7)
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index 99a610487fe..c6eaa54c692 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -1100,7 +1100,7 @@ textual parts.")
1100 (format-time-string 1100 (format-time-string
1101 (format "%%d-%s-%%Y" 1101 (format "%%d-%s-%%Y"
1102 (upcase 1102 (upcase
1103 (car (rassoc (nth 4 (decode-time cutoff)) 1103 (car (rassoc (decoded-time-month (decode-time cutoff))
1104 parse-time-months)))) 1104 parse-time-months))))
1105 cutoff)))) 1105 cutoff))))
1106 (and (car result) 1106 (and (car result)