From unknown Fri Jul 18 08:21:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68969: [PATCH] Fix handling of delta values with negative month field Resent-From: =?UTF-8?Q?=C5=81ukasz?= Stelmach Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Feb 2024 13:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68969 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 68969@debbugs.gnu.org Cc: =?UTF-8?Q?=C5=81ukasz?= Stelmach X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.170731309412100 (code B ref -1); Wed, 07 Feb 2024 13:39:01 +0000 Received: (at submit) by debbugs.gnu.org; 7 Feb 2024 13:38:14 +0000 Received: from localhost ([127.0.0.1]:55898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXi7y-000396-6F for submit@debbugs.gnu.org; Wed, 07 Feb 2024 08:38:14 -0500 Received: from lists.gnu.org ([2001:470:142::17]:44982) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXi7w-00038r-Hi for submit@debbugs.gnu.org; Wed, 07 Feb 2024 08:38:12 -0500 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 1rXi7d-00080x-31 for bug-gnu-emacs@gnu.org; Wed, 07 Feb 2024 08:37:53 -0500 Received: from smtpo48.interia.pl ([217.74.67.48]) by eggs.gnu.org with esmtps (TLS1.2:RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXi7b-0000z6-67 for bug-gnu-emacs@gnu.org; Wed, 07 Feb 2024 08:37:52 -0500 Received: from localhost (unknown [213.134.160.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by poczta.interia.pl (INTERIA.PL) with ESMTPSA; Wed, 7 Feb 2024 14:37:45 +0100 (CET) From: =?UTF-8?Q?=C5=81ukasz?= Stelmach Date: Wed, 7 Feb 2024 14:37:39 +0100 Message-Id: <20240207133739.2419658-1-stlman@poczta.fm> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-IPL-Priority-Group: 0-0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poczta.fm; s=dk; t=1707313066; bh=535UFXVM7rjwOq0pcNt799rIoP5pWS4W6Ybg9P7WHC0=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=pfIbUNBwVMczM8+WtD/oBDArPGloT3j3YoAvTDz2pMFLBKs1VzAdzOtfDCIwGakTO uRgbs9kHQxL4rcqSmYmCHer1ynm/3jIBc4BQRY7vdwa8I2/XWSZG+CtW+sB+W6IFtW jwjU8g9ZZYsjcpdVuBDAEAjsNciP7Hnic3B4hddU= Received-SPF: pass client-ip=217.74.67.48; envelope-from=stlman@poczta.fm; helo=smtpo48.interia.pl X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) * lisp/calendar/time-date.el (decoded-time-add): If the new variable is less then zero, the year needs to be decremented by quotient of new and 12 increased by one. * test/lisp/calendar/time-date-tests.el (test-decoded-add): Add applicable test cases. --- lisp/calendar/time-date.el | 2 +- test/lisp/calendar/time-date-tests.el | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index e96e2e7e2db..68b05314f3c 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el @@ -473,7 +473,7 @@ decoded-time-add (when (decoded-time-month delta) (let ((new (+ (1- (decoded-time-month time)) (decoded-time-month delta)))) (setf (decoded-time-month time) (1+ (mod new 12))) - (cl-incf (decoded-time-year time) (/ new 12)))) + (cl-incf (decoded-time-year time) (- (/ new 12) (if (< new 0) 1 0))))) ;; Adjust for month length (as described in the doc string). (setf (decoded-time-day time) diff --git a/test/lisp/calendar/time-date-tests.el b/test/lisp/calendar/time-date-tests.el index 01f9f8a5108..4ca274fcec6 100644 --- a/test/lisp/calendar/time-date-tests.el +++ b/test/lisp/calendar/time-date-tests.el @@ -131,6 +131,18 @@ test-decoded-add (should (equal (decoded-time-add time (mdec :month 10)) '(12 15 16 8 5 2020 1 t 7200))) + (should (equal (decoded-time-add time (mdec :month -1)) + '(12 15 16 8 6 2019 1 t 7200))) + + (should (equal (decoded-time-add time (mdec :month -10)) + '(12 15 16 8 9 2018 1 t 7200))) + + (should (equal (decoded-time-add time (mdec :month -14)) + '(12 15 16 8 5 2018 1 t 7200))) + + (should (equal (decoded-time-add time (mdec :month -24)) + '(12 15 16 8 7 2017 1 t 7200))) + (should (equal (decoded-time-add time (mdec :day 1)) '(12 15 16 9 7 2019 1 t 7200))) -- 2.39.2 From unknown Fri Jul 18 08:21:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68969: [PATCH] Fix handling of delta values with negative month field Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 23 Feb 2025 01:00:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68969 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: =?UTF-8?Q?=C5=81ukasz?= Stelmach Cc: 68969@debbugs.gnu.org Received: via spool by 68969-submit@debbugs.gnu.org id=B68969.17402723873093 (code B ref 68969); Sun, 23 Feb 2025 01:00:01 +0000 Received: (at 68969) by debbugs.gnu.org; 23 Feb 2025 00:59:47 +0000 Received: from localhost ([127.0.0.1]:58094 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tm0LT-0000nn-5v for submit@debbugs.gnu.org; Sat, 22 Feb 2025 19:59:47 -0500 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:60432) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tm0LQ-0000nR-9y for 68969@debbugs.gnu.org; Sat, 22 Feb 2025 19:59:45 -0500 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5e0373c7f55so5069940a12.0 for <68969@debbugs.gnu.org>; Sat, 22 Feb 2025 16:59:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740272378; x=1740877178; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z15fUt6iePZlrCSUxp01lib8hqENny0adAd3fWQ4kT4=; b=I0dkEOYD8oUmmjYJR/uxt4IL5vh3TmfB/q4azTSG56g5UpDftK6SWuiRYrRjZAQHdJ A4m8FAJku31P9wfl0hJivEl66VNqHzedWOeBfOJFMG8E40hBMv3JcDm6ByOAVz3ANtwm YfPxedVVcyH/rUYpfFIGLXykYfNz2mFmE+50NfEEY2Cw+6JfRCZXdbpDKGd2RyGNdfa0 gG47Yx9diXk9iKDgyl3CbN6oVgBvznf7YWwDnUHJiaG5T8BdMQVlScNaHiVrg6skviwv tJJcLd5I98+fnZx7LSb1ZEfihL5ZFxQXQg7PqSljvJIqXMvgirAXSh+Gs3AcmvUxibGs wHlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740272378; x=1740877178; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Z15fUt6iePZlrCSUxp01lib8hqENny0adAd3fWQ4kT4=; b=DxDFvmSlVehuA0YMuIUsZoZqyjDocqUA3AkGJP7UDKLiH+dTXhAzi3P6vWd/xnsWcX fSRrVnTJI/SWK+6cuGfPL1eajzSjTsLm2vKvBppOHElRkefX2Eq38UWP2A+B2zZTlAdw nyxBfscNQ0UsxBxe1OAzcS3eCIb+brKVqyrwadrR0vsvyRhfeBV5nvMw6boOFqBNGWfX ZIzHhXkNoSRpH1x7UKlQmGA2SPGYKxTPPhSQSYFIsGAdQbQZfd7k2+2sG52TKaRFtqiJ N20wyZalOfHuxYv+Ce968E9PGavx3fgMOVzOKN1C3z2CJLSjTJErVYb/S4enfd6dA7Qf Qt7g== X-Gm-Message-State: AOJu0YytRc78YNX6KFhyR64tEisuGsF3AbXmjAsBr/dQQIZCT6u9gYuL ajBQBW2v+oreyYfWqSVxOoN3IvGoJlwoYC0l/nQyGpihrb7O1IXq9VH8Is/loAwVeTLp2qf/jdx rm66WzP9IBa383/D2+CRgl8PQluE= X-Gm-Gg: ASbGncvqWA+xhgra/2GHJJubtRaF2Oq1VlwL6hnN70dSerHzXvo6RKmojhNpATolO/Z yePtEMsLGOnMJtY0oJ72XewuqNDAzoWKTKPWhLM7YhdLwalBj75mH6Ii06jC5B+IjS90EkBQ+g2 HHZ/aophJx X-Google-Smtp-Source: AGHT+IHEz4OWt8WP7H14WL83Jz6mkse8O5PAgalq1UnwyIAIxzxOUTUJEr8b6b4PkQjXuMLZmSmEp9LVsIcOaef01ME= X-Received: by 2002:a05:6402:50ca:b0:5e0:4e59:27a6 with SMTP id 4fb4d7f45d1cf-5e0b725077emr7828650a12.31.1740272378038; Sat, 22 Feb 2025 16:59:38 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 23 Feb 2025 00:59:37 +0000 From: Stefan Kangas In-Reply-To: <20240207133739.2419658-1-stlman@poczta.fm> References: <20240207133739.2419658-1-stlman@poczta.fm> MIME-Version: 1.0 Date: Sun, 23 Feb 2025 00:59:37 +0000 X-Gm-Features: AWEUYZl4cr7K6sk8eiIkFlgHCjq4DT7Jf7-h9jUWsU8uP96QI0osV75FYWhW7Bw Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) =C5=81ukasz Stelmach writes: > * lisp/calendar/time-date.el (decoded-time-add): If the new > variable is less then zero, the year needs to be decremented > by quotient of new and 12 increased by one. > * test/lisp/calendar/time-date-tests.el (test-decoded-add): > Add applicable test cases. > --- > lisp/calendar/time-date.el | 2 +- > test/lisp/calendar/time-date-tests.el | 12 ++++++++++++ > 2 files changed, 13 insertions(+), 1 deletion(-) Thanks, and sorry for the late reply here. Could you please explain what is the issue that this patch fixes? Is there a concrete use case that made you run into this? > diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el > index e96e2e7e2db..68b05314f3c 100644 > --- a/lisp/calendar/time-date.el > +++ b/lisp/calendar/time-date.el > @@ -473,7 +473,7 @@ decoded-time-add > (when (decoded-time-month delta) > (let ((new (+ (1- (decoded-time-month time)) (decoded-time-month d= elta)))) > (setf (decoded-time-month time) (1+ (mod new 12))) > - (cl-incf (decoded-time-year time) (/ new 12)))) > + (cl-incf (decoded-time-year time) (- (/ new 12) (if (< new 0) 1 = 0))))) > > ;; Adjust for month length (as described in the doc string). > (setf (decoded-time-day time) > diff --git a/test/lisp/calendar/time-date-tests.el b/test/lisp/calendar/t= ime-date-tests.el > index 01f9f8a5108..4ca274fcec6 100644 > --- a/test/lisp/calendar/time-date-tests.el > +++ b/test/lisp/calendar/time-date-tests.el > @@ -131,6 +131,18 @@ test-decoded-add > (should (equal (decoded-time-add time (mdec :month 10)) > '(12 15 16 8 5 2020 1 t 7200))) > > + (should (equal (decoded-time-add time (mdec :month -1)) > + '(12 15 16 8 6 2019 1 t 7200))) > + > + (should (equal (decoded-time-add time (mdec :month -10)) > + '(12 15 16 8 9 2018 1 t 7200))) > + > + (should (equal (decoded-time-add time (mdec :month -14)) > + '(12 15 16 8 5 2018 1 t 7200))) > + > + (should (equal (decoded-time-add time (mdec :month -24)) > + '(12 15 16 8 7 2017 1 t 7200))) > + > (should (equal (decoded-time-add time (mdec :day 1)) > '(12 15 16 9 7 2019 1 t 7200))) From unknown Fri Jul 18 08:21:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68969: [PATCH] Fix handling of delta values with negative month field Resent-From: =?UTF-8?Q?=C5=81ukasz?= Stelmach Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Feb 2025 13:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68969 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Kangas Cc: 68969@debbugs.gnu.org, =?UTF-8?Q?=C5=81ukasz?= Stelmach Received: via spool by 68969-submit@debbugs.gnu.org id=B68969.17405755471053 (code B ref 68969); Wed, 26 Feb 2025 13:13:02 +0000 Received: (at 68969) by debbugs.gnu.org; 26 Feb 2025 13:12:27 +0000 Received: from localhost ([127.0.0.1]:51470 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tnHD8-0000Gv-QJ for submit@debbugs.gnu.org; Wed, 26 Feb 2025 08:12:27 -0500 Received: from smtpo49.interia.pl ([217.74.67.49]:39477) by debbugs.gnu.org with esmtps (TLS1.2:RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tnHD6-0000Gc-9e for 68969@debbugs.gnu.org; Wed, 26 Feb 2025 08:12:25 -0500 Received: from localhost (89-64-83-179.dynamic.chello.pl [89.64.83.179]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by poczta.interia.pl (INTERIA.PL) with ESMTPSA; Wed, 26 Feb 2025 14:12:15 +0100 (CET) From: =?UTF-8?Q?=C5=81ukasz?= Stelmach References: <20240207133739.2419658-1-stlman@poczta.fm> X-Hashcash: 1:24:250226:68969@debbugs.gnu.org::OpSmKNJQsqHxLwiI:GXvU X-Hashcash: 1:24:250226:stlman@poczta.fm::8zue2x9/0vmLdOKu:gyoT X-Hashcash: 1:24:250226:stefankangas@gmail.com::WO2YDFt6XhaDugmI:0HGU+ Date: Wed, 26 Feb 2025 14:12:13 +0100 In-Reply-To: (Stefan Kangas's message of "Sun, 23 Feb 2025 00:59:37 +0000") Message-ID: <877c5cn93m.fsf%stlman@poczta.fm> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-IPL-Priority-Group: 0-0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poczta.fm; s=dk; t=1740575537; bh=e6SM2o/LwLtmDPgXiSo53jpwk6oD0eY8IThhfbc05ko=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=nde1DnX6PkX44beaUfQjnHw4ME80lP85ETKCkzhf3033AjAwrKAsbOioYakgFbaXf 2cuJKd7oVA8o0Y7Mp5MbS4gNT/TbCqYHJuW09D2ANtMB4o6JFwBg77QekMalZALz5z QxS/WH9pGlBzyKBd4pMqLl6qLCBHjAP0TlHlZghQ= X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Stefan Kangas writes: > =C5=81ukasz Stelmach writes: > >> * lisp/calendar/time-date.el (decoded-time-add): If the new >> variable is less then zero, the year needs to be decremented >> by quotient of new and 12 increased by one. >> * test/lisp/calendar/time-date-tests.el (test-decoded-add): >> Add applicable test cases. >> --- >> lisp/calendar/time-date.el | 2 +- >> test/lisp/calendar/time-date-tests.el | 12 ++++++++++++ >> 2 files changed, 13 insertions(+), 1 deletion(-) > > Thanks, and sorry for the late reply here. > > Could you please explain what is the issue that this patch fixes? Is > there a concrete use case that made you run into this? I was playing with Gnus' message list limiting gnus-summary-limit-to-age[1] and making my own lksz-gnus-summary-limit-to-month before sending this patch, but honestly I can't remember exactly. Beginning of a year may suggest that I was moving some e-mail messages between archive folders and something wasn't right across the year boundary. This is as close as I can guess. I still believe, however, the patch as it is needed and makes sense. [1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D58820 =2D-=20 Kind regards, =C5=81ukasz Stelmach --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGTBAEBCgB9FiEEkPlMeih05HaDBMFPALaXbGOR03EFAme/Ey9fFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDkw Rjk0QzdBMjg3NEU0NzY4MzA0QzE0RjAwQjY5NzZDNjM5MUQzNzEACgkQALaXbGOR 03EHNAf9FqyDFKyj6KjlQgF2Y9pjZUgNpU/AlTTKmcj/lE7EWj3l2D3/Re1pQVcd qsH/Vvi1gyUFESLHiJoE8dyAw1aFLh3GOuocIudlrQ2maopSN+klHw578VW+YpEb cvad4VF13qMVDDzHovxGk6E5v1gNdjWfEdmg6hy6sx89bTEt6ueCcUBeqRlwIpr5 ed+bDfQtIIVZWTwktvZyvU//UdGqlxHYOLG353FB5wxnYLADtlXlJnL5n8uIbMMB 8XyVNNisdmIw1P9TSpWe09cyxIW8yOw8gPfbvk/DzISIqDlV/EQszYfS1pbxF/M4 AYFiDCto4Rda18+GPFt9KKmhxPKr1A== =nrSY -----END PGP SIGNATURE----- --=-=-=-- From unknown Fri Jul 18 08:21:56 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: =?UTF-8?Q?=C5=81ukasz?= Stelmach Subject: bug#68969: closed (Re: bug#68969: [PATCH] Fix handling of delta values with negative month field) Message-ID: References: <20240207133739.2419658-1-stlman@poczta.fm> X-Gnu-PR-Message: they-closed 68969 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 68969@debbugs.gnu.org Date: Sat, 01 Mar 2025 03:42:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1740800522-18182-1" This is a multi-part message in MIME format... ------------=_1740800522-18182-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #68969: [PATCH] Fix handling of delta values with negative month field which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 68969@debbugs.gnu.org. --=20 68969: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D68969 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1740800522-18182-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 68969-done) by debbugs.gnu.org; 1 Mar 2025 03:41:33 +0000 Received: from localhost ([127.0.0.1]:57428 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1toDjI-0004gk-1J for submit@debbugs.gnu.org; Fri, 28 Feb 2025 22:41:33 -0500 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]:42456) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1toDjF-0004fo-G1 for 68969-done@debbugs.gnu.org; Fri, 28 Feb 2025 22:41:30 -0500 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-ab744d5e567so470974766b.1 for <68969-done@debbugs.gnu.org>; Fri, 28 Feb 2025 19:41:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740800483; x=1741405283; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:from:to:cc:subject:date :message-id:reply-to; bh=VecsGGEZRkenZFCjfLhPlSACGYLYUHfGs/U0jJ7gVEk=; b=UAwAMj5hKVz38QTUO9kDx3RmZPIxda1m3X0drc7xvPYC4J57hVPWd4fYHajDVjYjIP 3FGkfv8Po9pIjyOihVHwR5SLT93nn6WQU/b5zEDu8+PnVPHEGQVRp9hL4nCRK+KaUyUy 8DG1+nljM0kK24i3tLrqxbIB2UIA1e9lDtSmzgMO3b3Rkd9tURhtiOpxACuHZ9oZse1c 4c57xnV1mpEedK++4okMgC9TNHX9guw/pFi0z2EgyJY3l3oCc2y8GpKxizuPz3rzwPPk 7rYJ8yyAJRAY86p9PXzYRmlk8lTh+Ft2gGkWBhw/LYaJkfxxQxZUoYHBjHtYEjZWiSCr k0DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740800483; x=1741405283; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=VecsGGEZRkenZFCjfLhPlSACGYLYUHfGs/U0jJ7gVEk=; b=Mrqh9GI3bTgd5E4rRMZ5+1G8Mo2PS9l4HOisikE5qWeXM0ggFJNTvXz1evpWnga4KI r4WNm9SKknYAREthCe67v+n9j9CaKngOddVCnIiOB7FpSDIYUaxhGGkwkRrlVOv1dnEw ke8bOwaCgpoPu0lUgqe42hBbYHzOq9o5XmKIKFcUPFlPhOnB4VHrduKEZ+J/yFeOdMje puHQDkQBy6jTVUjVUL21NtgVsYRXZlnxIeClD5EcGejILi5sbfokeOLolrT7usYGM0VP i3c6o1GpJubmOxRxaAosK5uDZTlsH1TW/45LjYUP6ax9YHskw6++ACjsqly5px1+1QL7 SWrg== X-Gm-Message-State: AOJu0Yy/TJMAKpCb0CfDkmOTnstnpKYoNkRD6JPw6TUlKCc6NZQKQGrR 6mxoYN+CViQH3vw8M+mvf93g027xgGbrBF30NWg6YffBwi44RIxD7OpnXxb0vKp6yWS7hsAI3GF VvxZJePdjm6b7QBv/zZzcThi6W92WYvDf9kw= X-Gm-Gg: ASbGnctX/rcXju11aP4wj6/f4zrkfyux6Y/53UFFMlLOGcgja9jfNroe4WTxcDQ7cZZ AjnA9Y3fbAEjNgCL+V5QKMuFsnDwEIwVIz0BFuhnPEGUy4QTtnFq+kcbzQbEgYexCDE2gxyFpu3 n35QCjNRUEeOzSaKaYneu/9h8McSo= X-Google-Smtp-Source: AGHT+IEQeNs/5n2CZ2cPmoT7BKum6gMcywN/ZUIVxG0nUMRW0QVLY7kmZYK9jOj+e6x31mV/HYCFrBZIan+qiELXyMs= X-Received: by 2002:a17:906:478b:b0:abf:5778:f93e with SMTP id a640c23a62f3a-abf577952femr18710366b.20.1740800483167; Fri, 28 Feb 2025 19:41:23 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 28 Feb 2025 19:41:22 -0800 From: Stefan Kangas In-Reply-To: <877c5cn93m.fsf%stlman@poczta.fm> References: <20240207133739.2419658-1-stlman@poczta.fm> <877c5cn93m.fsf%stlman@poczta.fm> MIME-Version: 1.0 Date: Fri, 28 Feb 2025 19:41:22 -0800 X-Gm-Features: AQ5f1JooMuffvIPMp3-Oa6t8V9ay5FRNMQzk98cKBRVy7aiVzlOsUHO6lNjNwPQ Message-ID: Subject: Re: bug#68969: [PATCH] Fix handling of delta values with negative month field To: =?UTF-8?Q?=C5=81ukasz_Stelmach?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 68969-done Cc: 68969-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Version: 31.1 =C5=81ukasz Stelmach writes: > Stefan Kangas writes: > >> =C5=81ukasz Stelmach writes: >> >>> * lisp/calendar/time-date.el (decoded-time-add): If the new >>> variable is less then zero, the year needs to be decremented >>> by quotient of new and 12 increased by one. >>> * test/lisp/calendar/time-date-tests.el (test-decoded-add): >>> Add applicable test cases. >>> --- >>> lisp/calendar/time-date.el | 2 +- >>> test/lisp/calendar/time-date-tests.el | 12 ++++++++++++ >>> 2 files changed, 13 insertions(+), 1 deletion(-) >> >> Thanks, and sorry for the late reply here. >> >> Could you please explain what is the issue that this patch fixes? Is >> there a concrete use case that made you run into this? > > I was playing with Gnus' message list limiting > gnus-summary-limit-to-age[1] and making my own > lksz-gnus-summary-limit-to-month before sending this patch, but honestly > I can't remember exactly. Beginning of a year may suggest that I was > moving some e-mail messages between archive folders and something wasn't > right across the year boundary. This is as close as I can guess. > > I still believe, however, the patch as it is needed and makes sense. > > [1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D58820 Thanks for the patch. I installed it on master. I'm therefore closing this bug report. ------------=_1740800522-18182-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 7 Feb 2024 13:38:14 +0000 Received: from localhost ([127.0.0.1]:55898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXi7y-000396-6F for submit@debbugs.gnu.org; Wed, 07 Feb 2024 08:38:14 -0500 Received: from lists.gnu.org ([2001:470:142::17]:44982) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXi7w-00038r-Hi for submit@debbugs.gnu.org; Wed, 07 Feb 2024 08:38:12 -0500 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 1rXi7d-00080x-31 for bug-gnu-emacs@gnu.org; Wed, 07 Feb 2024 08:37:53 -0500 Received: from smtpo48.interia.pl ([217.74.67.48]) by eggs.gnu.org with esmtps (TLS1.2:RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXi7b-0000z6-67 for bug-gnu-emacs@gnu.org; Wed, 07 Feb 2024 08:37:52 -0500 Received: from localhost (unknown [213.134.160.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by poczta.interia.pl (INTERIA.PL) with ESMTPSA; Wed, 7 Feb 2024 14:37:45 +0100 (CET) From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= To: bug-gnu-emacs@gnu.org Subject: [PATCH] Fix handling of delta values with negative month field Date: Wed, 7 Feb 2024 14:37:39 +0100 Message-Id: <20240207133739.2419658-1-stlman@poczta.fm> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-IPL-Priority-Group: 0-0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poczta.fm; s=dk; t=1707313066; bh=535UFXVM7rjwOq0pcNt799rIoP5pWS4W6Ybg9P7WHC0=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=pfIbUNBwVMczM8+WtD/oBDArPGloT3j3YoAvTDz2pMFLBKs1VzAdzOtfDCIwGakTO uRgbs9kHQxL4rcqSmYmCHer1ynm/3jIBc4BQRY7vdwa8I2/XWSZG+CtW+sB+W6IFtW jwjU8g9ZZYsjcpdVuBDAEAjsNciP7Hnic3B4hddU= Received-SPF: pass client-ip=217.74.67.48; envelope-from=stlman@poczta.fm; helo=smtpo48.interia.pl X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: =?UTF-8?q?=C5=81ukasz=20Stelmach?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) * lisp/calendar/time-date.el (decoded-time-add): If the new variable is less then zero, the year needs to be decremented by quotient of new and 12 increased by one. * test/lisp/calendar/time-date-tests.el (test-decoded-add): Add applicable test cases. --- lisp/calendar/time-date.el | 2 +- test/lisp/calendar/time-date-tests.el | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index e96e2e7e2db..68b05314f3c 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el @@ -473,7 +473,7 @@ decoded-time-add (when (decoded-time-month delta) (let ((new (+ (1- (decoded-time-month time)) (decoded-time-month delta)))) (setf (decoded-time-month time) (1+ (mod new 12))) - (cl-incf (decoded-time-year time) (/ new 12)))) + (cl-incf (decoded-time-year time) (- (/ new 12) (if (< new 0) 1 0))))) ;; Adjust for month length (as described in the doc string). (setf (decoded-time-day time) diff --git a/test/lisp/calendar/time-date-tests.el b/test/lisp/calendar/time-date-tests.el index 01f9f8a5108..4ca274fcec6 100644 --- a/test/lisp/calendar/time-date-tests.el +++ b/test/lisp/calendar/time-date-tests.el @@ -131,6 +131,18 @@ test-decoded-add (should (equal (decoded-time-add time (mdec :month 10)) '(12 15 16 8 5 2020 1 t 7200))) + (should (equal (decoded-time-add time (mdec :month -1)) + '(12 15 16 8 6 2019 1 t 7200))) + + (should (equal (decoded-time-add time (mdec :month -10)) + '(12 15 16 8 9 2018 1 t 7200))) + + (should (equal (decoded-time-add time (mdec :month -14)) + '(12 15 16 8 5 2018 1 t 7200))) + + (should (equal (decoded-time-add time (mdec :month -24)) + '(12 15 16 8 7 2017 1 t 7200))) + (should (equal (decoded-time-add time (mdec :day 1)) '(12 15 16 9 7 2019 1 t 7200))) -- 2.39.2 ------------=_1740800522-18182-1--