[gnus git] branch master updated: m0-11-67-g7572373 =1= Simplify use of current-time and friends
Katsumi <[email protected]> Wed, 29 Oct 2014 03:19:57 +0100
| Newsgroups | gmane.emacs.gnus.cvs |
|---|---|
| Message-ID | <[email protected]> |
via 75723739287ba519d3cb65f4d7caaffcb662ebd3 (commit)
from 8bb74da7932287e4f5fd806aa6c7dae35256bdce (commit)
- Log -----------------------------------------------------------------
commit 75723739287ba519d3cb65f4d7caaffcb662ebd3
Author: Paul Eggert <[email protected]>
Date: Wed Oct 29 02:19:38 2014 +0000
Simplify use of current-time and friends
* gnus-delay.el (gnus-delay-article):
* gnus-sum.el (gnus-summary-read-document):
* gnus-util.el (gnus-seconds-today, gnus-seconds-month):
* message.el (message-make-expires-date):
Omit unnecessary call to current-time.
* gnus-util.el (gnus-float-time): Simplify to an alias because
time-to-seconds now behaves like float-time with respect to nil arg.
(gnus-seconds-year): Don't call current-time twice to get the current
time stamp, as this can lead to inconsistent results.
* time-date.el (time-to-seconds) [!float-time]:
Use current time if arg is nil, to be compatible with float-time.
(time-date--day-in-year): New function, with most of the guts of
the old time-to-day-in-year.
(time-to-day-in-year): Use it.
(time-to-days): Use it, to avoid decoding the same time stamp twice.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ad98a15..250d2e8 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,22 @@
+2014-10-29 Paul Eggert <[email protected]>
+
+ Simplify use of current-time and friends.
+ * gnus-delay.el (gnus-delay-article):
+ * gnus-sum.el (gnus-summary-read-document):
+ * gnus-util.el (gnus-seconds-today, gnus-seconds-month):
+ * message.el (message-make-expires-date):
+ Omit unnecessary call to current-time.
+ * gnus-util.el (gnus-float-time): Simplify to an alias because
+ time-to-seconds now behaves like float-time with respect to nil arg.
+ (gnus-seconds-year): Don't call current-time twice to get the current
+ time stamp, as this can lead to inconsistent results.
+ * time-date.el (time-to-seconds) [!float-time]:
+ Use current time if arg is nil, to be compatible with float-time.
+ (time-date--day-in-year): New function, with most of the guts of
+ the old time-to-day-in-year.
+ (time-to-day-in-year): Use it.
+ (time-to-days): Use it, to avoid decoding the same time stamp twice.
+
2014-10-27 Katsumi Yamaoka <[email protected]>
* gnus.el (gnus-mode-line-buffer-identification):
diff --git a/lisp/gnus-delay.el b/lisp/gnus-delay.el
index 75b967e..2a286da 100644
--- a/lisp/gnus-delay.el
+++ b/lisp/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 (apply 'vector (decode-time (current-time))))
+ (setq deadline (apply 'vector (decode-time)))
;; ... for minute and hour.
(aset deadline 1 minute)
(aset deadline 2 hour)
diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el
index db0242e..55a263d 100644
--- a/lisp/gnus-sum.el
+++ b/lisp/gnus-sum.el
@@ -9333,7 +9333,7 @@ Obeys the standard process/prefix convention."
((gnus-group-read-ephemeral-group
(setq vgroup (format
"nnvirtual:%s-%s" gnus-newsgroup-name
- (format-time-string "%Y%m%dT%H%M%S" (current-time))))
+ (format-time-string "%Y%m%dT%H%M%S")))
`(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
t
(cons (current-buffer) 'summary)))
diff --git a/lisp/gnus-util.el b/lisp/gnus-util.el
index fe4d707..15f3aed 100644
--- a/lisp/gnus-util.el
+++ b/lisp/gnus-util.el
@@ -313,14 +313,12 @@ Symbols are also allowed; their print names are used instead."
;; Every version of Emacs Gnus supports has built-in float-time.
;; The featurep test silences an irritating compiler warning.
-(eval-and-compile
+(defalias 'gnus-float-time
(if (or (featurep 'emacs)
(fboundp 'float-time))
- (defalias 'gnus-float-time 'float-time)
- (defun gnus-float-time (&optional time)
+ 'float-time 'time-to-seconds)
"Convert time value TIME to a floating point number.
-TIME defaults to the current time."
- (time-to-seconds (or time (current-time))))))
+TIME defaults to the current time.")
;;; Keymap macros.
@@ -389,19 +387,20 @@ TIME defaults to the current time."
(defun gnus-seconds-today ()
"Return the number of seconds passed today."
- (let ((now (decode-time (current-time))))
+ (let ((now (decode-time)))
(+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600))))
(defun gnus-seconds-month ()
"Return the number of seconds passed this month."
- (let ((now (decode-time (current-time))))
+ (let ((now (decode-time)))
(+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600)
(* (- (car (nthcdr 3 now)) 1) 3600 24))))
(defun gnus-seconds-year ()
"Return the number of seconds passed this year."
- (let ((now (decode-time (current-time)))
- (days (format-time-string "%j" (current-time))))
+ (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)
(* (- (string-to-number days) 1) 3600 24))))
diff --git a/lisp/message.el b/lisp/message.el
index 5ba42b1..59d22ef 100644
--- a/lisp/message.el
+++ b/lisp/message.el
@@ -5594,7 +5594,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 (current-time)))
+ (let* ((cur (decode-time))
(nday (+ days (nth 3 cur))))
(setf (nth 3 cur) nday)
(message-make-date (apply 'encode-time cur))))
diff --git a/lisp/time-date.el b/lisp/time-date.el
index 48fe229..82bc05f 100644
--- a/lisp/time-date.el
+++ b/lisp/time-date.el
@@ -44,7 +44,7 @@ The value of the last form in BODY is returned.
Each element of the list VARLIST is a list of the form
\(HIGH-SYMBOL LOW-SYMBOL MICRO-SYMBOL [PICO-SYMBOL [TYPE-SYMBOL]] TIME-VALUE).
-The time value TIME-VALUE is decoded and the result it bound to
+The time value TIME-VALUE is decoded and the result is bound to
the symbols HIGH-SYMBOL, LOW-SYMBOL and MICRO-SYMBOL.
The optional PICO-SYMBOL is bound to the picoseconds part.
@@ -147,10 +147,12 @@ If DATE lacks timezone information, GMT is assumed."
(or (featurep 'emacs)
(and (fboundp 'float-time)
(subrp (symbol-function 'float-time)))
- (defun time-to-seconds (time)
- "Convert time value TIME to a floating point number."
- (with-decoded-time-value ((high low micro pico type time))
- (+ (* 1.0 high 65536)
+ (defun time-to-seconds (&optional time)
+ "Convert optional value TIME to a floating point number.
+TIME defaults to the current time."
+ (with-decoded-time-value ((high low micro pico type
+ (or time (current-time))))
+ (+ (* high 65536.0)
low
(/ (+ (* micro 1e6) pico) 1e12))))))
@@ -272,11 +274,9 @@ DATE1 and DATE2 should be date-time strings."
(not (zerop (% year 100))))
(zerop (% year 400))))
-;;;###autoload
-(defun time-to-day-in-year (time)
- "Return the day number within the year corresponding to TIME."
- (let* ((tim (decode-time time))
- (month (nth 4 tim))
+(defun time-date--day-in-year (tim)
+ "Return the day number within the year corresponding to the decoded time TIM."
+ (let* ((month (nth 4 tim))
(day (nth 3 tim))
(year (nth 5 tim))
(day-of-year (+ day (* 31 (1- month)))))
@@ -287,13 +287,18 @@ DATE1 and DATE2 should be date-time strings."
day-of-year))
;;;###autoload
+(defun time-to-day-in-year (time)
+ "Return the day number within the year corresponding to TIME."
+ (time-date--day-in-year (decode-time time)))
+
+;;;###autoload
(defun time-to-days (time)
"The number of days between the Gregorian date 0001-12-31bce and TIME.
TIME should be a time value.
The Gregorian date Sunday, December 31, 1bce is imaginary."
(let* ((tim (decode-time time))
(year (nth 5 tim)))
- (+ (time-to-day-in-year time) ; Days this year
+ (+ (time-date--day-in-year tim) ; Days this year
(* 365 (1- year)) ; + Days in prior years
(/ (1- year) 4) ; + Julian leap years
(- (/ (1- year) 100)) ; - century years
-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.
Summary of changes:
lisp/ChangeLog | 19 +++++++++++++++++++
lisp/gnus-delay.el | 2 +-
lisp/gnus-sum.el | 2 +-
lisp/gnus-util.el | 19 +++++++++----------
lisp/message.el | 2 +-
lisp/time-date.el | 27 ++++++++++++++++-----------
6 files changed, 47 insertions(+), 24 deletions(-)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".
The branch, master has been updated
hooks/post-receive
--
Gnus Project