From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ulrich Mueller Newsgroups: gmane.emacs.bugs Subject: bug#72570: 31.0.50; Regression in date-to-time Date: Mon, 12 Aug 2024 09:27:11 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28316"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 72570@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 12 09:27:56 2024 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 1sdPT9-0007EX-57 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 12 Aug 2024 09:27:55 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdPSn-0007jx-EG; Mon, 12 Aug 2024 03:27:33 -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 1sdPSl-0007jW-HT for bug-gnu-emacs@gnu.org; Mon, 12 Aug 2024 03:27:31 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdPSl-00049N-7h for bug-gnu-emacs@gnu.org; Mon, 12 Aug 2024 03:27:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=lrBvG95vGbUwE7/kipg0AVp1RDKEPMD0G+ObhYeyUVM=; b=Qn1LDOMgAWnGqF7jGOWbu1HF6kk6jgYW5ub8s16Wp66YgpDy64o3LEiy5SEbR5iyP6DYTXzf7KmQA0+uR36l4cMZzAigNFGwTZj6WOrJcwJbT5dRQStgtVS8/3tct8dJeq08veriA7l4J42iKFMrRBuUzS36vOcrZDNVxeo0PRMSXeQjaD6lZvUetdxHZ47Mi0gxo5UZh1PzPMF7y8CUJePS5To7G7jQdiLoYUxoekZvwI19CLt9R7Ei+id5XVc+KsZX2x1AW02tqkQl+NVB6mpO4Bxa0F0h7QkJH4IyhtaxoI1yuryNYIBAAqJ+msF80m7JFu84vOmnShMpC+ACmA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sdPTG-0001Ao-EK for bug-gnu-emacs@gnu.org; Mon, 12 Aug 2024 03:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ulrich Mueller Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 12 Aug 2024 07:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72570 X-GNU-PR-Package: emacs Original-Received: via spool by 72570-submit@debbugs.gnu.org id=B72570.17234476794501 (code B ref 72570); Mon, 12 Aug 2024 07:28:02 +0000 Original-Received: (at 72570) by debbugs.gnu.org; 12 Aug 2024 07:27:59 +0000 Original-Received: from localhost ([127.0.0.1]:42331 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sdPTD-0001AX-5Q for submit@debbugs.gnu.org; Mon, 12 Aug 2024 03:27:59 -0400 Original-Received: from woodpecker.gentoo.org ([140.211.166.183]:39892 helo=smtp.gentoo.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sdPTB-0001AG-J2 for 72570@debbugs.gnu.org; Mon, 12 Aug 2024 03:27:58 -0400 In-Reply-To: (Ulrich Mueller's message of "Sun, 11 Aug 2024 10:57:57 +0200") 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:290038 Archived-At: --=-=-= Content-Type: text/plain Attached patch will make date-to-time work as documented. Alternatively, maybe it would be more consistent with other time functions in Emacs if date-to-time would use local time as the default (i.e. what is assumed by the current unit test in time-date-tests.el). However, the fallback code uses Universal Time, and I don't see an easy way to modify it for local time. The problem is that timezone-make-date-arpa-standard would need an explicit timezone as its second argument, which we don't know. We cannot use (current-time-zone) there, because it's the timezone of the current time, not the one of the to-be-converted timestamp. (For example, in the Europe/Berlin timezone, (current-time-zone) returns (7200 "CEST"), while for conversion of "2024-01-01 00:00:00" one would need (3600 "CET")). (BTW, the code in timezone.el is very brittle. For example, (timezone-make-date-arpa-standard "2024-01-01") signals a wrong-type-argument error from 'capitalize'.) --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=0001-Make-date-to-time-without-timezone-work-as-documente.patch >From 6c55891b5850c923196187b21b73f52d474c325a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20M=C3=BCller?= Date: Mon, 12 Aug 2024 07:30:01 +0200 Subject: [PATCH] Make date-to-time without timezone work as documented * lisp/calendar/time-date.el (date-to-time): Assume Universal Time rather than local time when no timezone is specified. (Bug#72570) * test/lisp/calendar/time-date-tests.el (test-date-to-time): Update test. --- lisp/calendar/time-date.el | 5 +++-- test/lisp/calendar/time-date-tests.el | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index eca80f1e8b6..2f3ef0d8b4c 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el @@ -156,7 +156,7 @@ date-to-time (condition-case err (let ((parsed (parse-time-string date))) (when (decoded-time-year parsed) - (decoded-time-set-defaults parsed)) + (decoded-time-set-defaults parsed t)) (encode-time parsed)) (error (let ((overflow-error '(error "Specified time is not representable"))) @@ -164,7 +164,8 @@ date-to-time (signal (car err) (cdr err)) (condition-case err (encode-time (parse-time-string - (timezone-make-date-arpa-standard date))) + (timezone-make-date-arpa-standard + date nil '(0 "UTC")))) (error (if (equal err overflow-error) (signal (car err) (cdr err)) diff --git a/test/lisp/calendar/time-date-tests.el b/test/lisp/calendar/time-date-tests.el index 6512dd0bd07..d7d39f050b7 100644 --- a/test/lisp/calendar/time-date-tests.el +++ b/test/lisp/calendar/time-date-tests.el @@ -42,8 +42,12 @@ test-obsolete-encode-time-value '(1 2 3 4)))) (ert-deftest test-date-to-time () - (should (equal (format-time-string "%F %T" (date-to-time "2021-12-04")) - "2021-12-04 00:00:00"))) + (should (equal (format-time-string + "%F %T" (date-to-time "2021-12-04") t) + "2021-12-04 00:00:00")) + (should (equal (format-time-string + "%F %T" (date-to-time "2021-12-04 00:00:00 +0100") t) + "2021-12-03 23:00:00"))) (ert-deftest test-days-between () (should (equal (days-between "2021-10-22" "2020-09-29") 388))) -- 2.45.2 --=-=-=--