From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?=C5=81ukasz?= Stelmach Newsgroups: gmane.emacs.bugs 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 Message-ID: <20221027185006.1033130-1-stlman@poczta.fm> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34529"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?UTF-8?Q?=C5=81ukasz?= Stelmach To: 58820@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 27 21:27:17 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oo8X6-0008nv-Sq for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 27 Oct 2022 21:27:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oo84r-0002Pr-ES; Thu, 27 Oct 2022 14:58:05 -0400 Original-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 ) id 1oo84o-0002PZ-Uf for bug-gnu-emacs@gnu.org; Thu, 27 Oct 2022 14:58:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oo84o-0006el-HE for bug-gnu-emacs@gnu.org; Thu, 27 Oct 2022 14:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oo84o-0005qe-CF for bug-gnu-emacs@gnu.org; Thu, 27 Oct 2022 14:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?=C5=81ukasz?= Stelmach Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 27 Oct 2022 18:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58820 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.166689705022434 (code B ref -1); Thu, 27 Oct 2022 18:58:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Oct 2022 18:57:30 +0000 Original-Received: from localhost ([127.0.0.1]:59323 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo84H-0005pl-Nv for submit@debbugs.gnu.org; Thu, 27 Oct 2022 14:57:30 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:55824) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo84E-0005pc-JX for submit@debbugs.gnu.org; Thu, 27 Oct 2022 14:57:28 -0400 Original-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 ) id 1oo847-0002Kh-Gc for bug-gnu-emacs@gnu.org; Thu, 27 Oct 2022 14:57:19 -0400 Original-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 ) id 1oo841-0006bI-VG for bug-gnu-emacs@gnu.org; Thu, 27 Oct 2022 14:57:18 -0400 Original-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) X-Mailer: git-send-email 2.30.2 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@poczta.fm; 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246360 Archived-At: * 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