GNU bug report logs - #58820
[PATCH] Calculate age cutoff at n-th midnight instead of n*24h mark

Previous Next

Package: emacs;

Reported by: Łukasz Stelmach <stlman <at> poczta.fm>

Date: Thu, 27 Oct 2022 18:58:02 UTC

Severity: wishlist

Tags: patch

Fixed in version 30.1

Done: Eric Abrahamsen <eric <at> ericabrahamsen.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Łukasz Stelmach <stlman <at> poczta.fm>
To: 58820 <at> debbugs.gnu.org
Cc: Łukasz Stelmach <stlman <at> poczta.fm>
Subject: bug#58820: [PATCH] Calculate age cutoff at n-th midnight instead of n*24h mark
Date: Thu, 27 Oct 2022 20:50:06 +0200
* lisp/gnus/gnus-sum.el (gnus-summary-limit-to-age): Calculate cutoff to
point to n-th past midnight (1st is 00:00 today).  This way messages sent
between n*24h mark and the next midnight will be excluded (or included
if limitting to younger messages), which seems more intuitive when users
are asked to enter age in days.
---
 lisp/gnus/gnus-sum.el | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 18ba55a439..a15dedeccf 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -8323,8 +8323,9 @@ articles."
 
 (defun gnus-summary-limit-to-age (age &optional younger-p)
   "Limit the summary buffer to articles that are older than (or equal) AGE days.
-If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
-articles that are younger than AGE days."
+Days are counted at midnight so with AGE equal 1 messages sent before 00:00
+today will be included (or excluded).  If YOUNGER-P (the prefix) is non-nil,
+limit the summary buffer to articles that are younger than AGE days."
   (interactive
    (let ((younger current-prefix-arg)
 	 (days-got nil)
@@ -8347,15 +8348,17 @@ articles that are younger than AGE days."
      (list days younger))
    gnus-summary-mode)
   (prog1
-      (let ((data gnus-newsgroup-data)
-	    (cutoff (days-to-time age))
-	    articles d date is-younger)
+      (let* ((data gnus-newsgroup-data)
+	     (now (append '(0 0 0) (cdddr (decode-time))))
+	     (delta (make-decoded-time :day (* -1 (- age 1))))
+	     (cutoff (encode-time (decoded-time-add now delta)))
+	     articles d date is-younger)
 	(while (setq d (pop data))
 	  (when (and (mail-header-p (gnus-data-header d))
 		     (setq date (mail-header-date (gnus-data-header d))))
 	    (setq is-younger (time-less-p
-			      (time-since (gnus-date-get-time date))
-			      cutoff))
+			      cutoff
+			      (gnus-date-get-time date)))
 	    (when (if younger-p
 		      is-younger
 		    (not is-younger))
-- 
2.30.2





This bug report was last modified 1 year and 280 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.