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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Łukasz Stelmach <stlman@HIDDEN>; Keywords: patch; dated Thu, 27 Oct 2022 18:58:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 27 Oct 2022 18:57:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 27 14:57:30 2022
Received: from localhost ([127.0.0.1]:59323 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oo84H-0005pl-Nv
	for submit <at> debbugs.gnu.org; Thu, 27 Oct 2022 14:57:30 -0400
Received: from lists.gnu.org ([209.51.188.17]:55824)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stlman@HIDDEN>) id 1oo84E-0005pc-JX
 for submit <at> debbugs.gnu.org; Thu, 27 Oct 2022 14:57:28 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <stlman@HIDDEN>) id 1oo847-0002Kh-Gc
 for bug-gnu-emacs@HIDDEN; Thu, 27 Oct 2022 14:57:19 -0400
Received: from smtpo76.interia.pl ([217.74.67.76])
 by eggs.gnu.org with esmtps (TLS1.2:RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <stlman@HIDDEN>) id 1oo841-0006bI-VG
 for bug-gnu-emacs@HIDDEN; Thu, 27 Oct 2022 14:57:18 -0400
Received: from localhost (89-64-89-35.dynamic.chello.pl [89.64.89.35])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest
 SHA256) (No client certificate requested)
 by www.poczta.fm (INTERIA.PL) with ESMTPSA;
 Thu, 27 Oct 2022 20:50:24 +0200 (CEST)
From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= <stlman@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Calculate age cutoff at n-th midnight instead of n*24h mark
Date: Thu, 27 Oct 2022 20:50:06 +0200
Message-Id: <20221027185006.1033130-1-stlman@HIDDEN>
X-Mailer: git-send-email 2.30.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=interia.pl;
 s=biztos; t=1666896626;
 bh=ZsUWkWEVMoeT2POPFE2aClErvduzNIvYdNVHJwMeWIQ=;
 h=From:To:Subject:Date:Message-Id:MIME-Version;
 b=fUeN1oOV5WgZKsXTcVBD4lVR9c4Jw3/Vnri/iwWnCjV2m0kkChBMYt42R04jMzlVn
 hy5mA7wlcGE4d+jssJVEQJSwKwr8K4aAlgEDB3LT2lTtg9Kh+kF4VB7iZjGMvH41MQ
 8EHisEaG5AfciVBbMQLP9quQaHKwSdcjf1+ZwtgA=
Received-SPF: pass client-ip=217.74.67.76; envelope-from=stlman@HIDDEN;
 helo=smtpo76.interia.pl
X-Spam_score_int: -25
X-Spam_score: -2.6
X-Spam_bar: --
X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,
 RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: submit
Cc: =?UTF-8?q?=C5=81ukasz=20Stelmach?= <stlman@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

* 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





Acknowledgement sent to Łukasz Stelmach <stlman@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#58820; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 11 Nov 2022 13:30:02 UTC

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