From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id SFiDGOmq9V+kUQAA0tVLHw (envelope-from ) for ; Wed, 06 Jan 2021 12:19:53 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id YGhuFOmq9V/FbgAA1q6Kng (envelope-from ) for ; Wed, 06 Jan 2021 12:19:53 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CCBF19402D4 for ; Wed, 6 Jan 2021 12:19:52 +0000 (UTC) Received: from localhost ([::1]:39624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kx7n5-0006or-PX for larch@yhetil.org; Wed, 06 Jan 2021 07:19:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kx7kq-0005th-JM for emacs-orgmode@gnu.org; Wed, 06 Jan 2021 07:17:33 -0500 Received: from forward2-smtp.messagingengine.com ([66.111.4.226]:50225) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kx7kn-0007Ew-Qs for emacs-orgmode@gnu.org; Wed, 06 Jan 2021 07:17:31 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailforward.nyi.internal (Postfix) with ESMTP id 89FE11943D75 for ; Wed, 6 Jan 2021 07:17:26 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 06 Jan 2021 07:17:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=kC/Epk Y5pzZuTkYMU7GR5EkdKmQmNjZaNvP/Cl5uWF0=; b=Y0s1xsG4T+182BexI8cXRO WAHj7PTPmTJFGXqcVLNvrHkKbYG9MKkFy4r0jvh0Bry6L2eOtlykMWNyMbAGj4IX XTExc8fySXt/4Uu4Zqtwm5W2vMIdmy9t+aoKkPX7G7Ff8v+csa00SSgqPfkxaOlu wESCtYk7fwlzTT4EYanrScm0BqMUErvsMYJUaaHz0IKJZu781As77SalgAp42lOI 6VQM8CmfrOtrYGLOY18241gopgQFL2rCFdb+QNZPEc/5LY1FaUxqDLTqjLyLqD7j o48rWtx560HTxCvmOaQuenum4/mvRBWd9PtJlzxALg1+++X5+2tYYwCUujkWtceA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdefledggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgohfhorhgsihguuggvnhfuohhrthfjughrucdlhe dttddmnecujfgurhephffvufgjfhffkfggtgesmhdtreertddttdenucfhrhhomheptfhi tghhrghrugcunfgrfihrvghntggvuceorhhitghhrghrugdrlhgrfihrvghntggvsehunh hiqdhtuhgvsghinhhgvghnrdguvgeqnecuggftrfgrthhtvghrnhepvefhvdefveevudej leeugfffveeuudekveehhfetudeljeetfedvtddtleejvddunecukfhppeegiedrhedrvd ehgedrvdehtdenucfhohhrsghiugguvghnufhorhhtjfgurhepfffhkffuvfggjggtfhes mhdtreertddttdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehrfihlsehfrghsthhmrghilhdrtghomh X-ME-Proxy: Received: from aquinas (hsi-kbw-046-005-254-250.hsi8.kabel-badenwuerttemberg.de [46.5.254.250]) by mail.messagingengine.com (Postfix) with ESMTPA id 32BE01080057 for ; Wed, 6 Jan 2021 07:17:26 -0500 (EST) Received: from rwl by aquinas with local (Exim 4.92) (envelope-from ) id 1kx7kN-0003ny-PH for emacs-orgmode@gnu.org; Wed, 06 Jan 2021 13:17:03 +0100 From: Richard Lawrence To: emacs-orgmode@gnu.org Subject: Re: Bug: incorrect timestamps with :time-prompt and datetrees In-Reply-To: <87eejfh0fm.fsf@aquinas> References: <87h7obh4ct.fsf@aquinas> <87eejfh0fm.fsf@aquinas> Date: Wed, 06 Jan 2021 13:16:53 +0100 Message-ID: <87ble2uuoa.fsf@aquinas> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: neutral client-ip=66.111.4.226; envelope-from=rwl@fastmail.com; helo=forward2-smtp.messagingengine.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NEUTRAL=0.779 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.04 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=Y0s1xsG4; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: CCBF19402D4 X-Spam-Score: -2.04 X-Migadu-Scanner: scn0.migadu.com X-TUID: oU5HqTnfZf6x --=-=-= Content-Type: text/plain Hi everyone, Richard Lawrence writes: > I can now confirm that this is the problem. It looks like what is happening here > is that the regex is meant to match a time range, but ends up matching > the date: thus a string like "12-31 13:00" gets mangled to "12 13:00" > and sent into org-read-date-analyze. > So I guess the solution is...a better regex is needed to cause this > branch to fire only in the intended case, namely, a time range. Here is a patch for this issue. It uses a narrower regex to match a time range. This regex requires time ranges to have ":MM" or an AM/PM specification in the end time, to prevent mangling strings that are interpreted as dates, like "11-12". This patch is a minimal change that gets the code working in the way that seems to have been intended, so it seems worth applying to maint. However, the way the code is intended to work doesn't seem right to me, because it simply throws away time range information at the time prompt. If you enter a time range like "13:00-14:00" at the time prompt, you will get a timestamp with "13:00" for the time when the %T template is expanded. (This is because org-capture-set-target-location uses the beginning of the entered time range to set :default-time, which must be an encoded time value, and there is no obvious way to set a time range.) This is a surprising contrast with the behavior of %^T, which preserves the time range information in the timestamp entered. But fixing this will be a larger change and possibly requires some discussion. -- Best, Richard --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-org-capture-fix-expansion-of-T-when-capturing-to-a-d.patch >From a41c751f15488a8b0d48d6b1b1744dbbc003f9f0 Mon Sep 17 00:00:00 2001 From: Richard Lawrence Date: Wed, 6 Jan 2021 11:53:42 +0100 Subject: [PATCH] org-capture: fix expansion of %T when capturing to a datetree * org-capture.el (org-capture-set-target-location): Use a narrower regular expression to replace a time range by its start time when setting :default-time, so that dates do not get mangled. TINYCHANGE --- lisp/org-capture.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index f40f2b335..df0eccdbb 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1038,12 +1038,12 @@ Store them in the capture property list." (apply #'encode-time 0 0 org-extend-today-until (cl-cdddr (decode-time prompt-time)))) - ((string-match "\\([^ ]+\\)-[^ ]+[ ]+\\(.*\\)" + ((string-match "\\(--?\\([012]?[0-9]\\)\\(\\(:[0-5][0-9]\\)\\|\\(am\\|AM\\|pm\\|PM\\)\\>\\)\\)\\(.*\\)" org-read-date-final-answer) ;; Replace any time range by its start. (apply #'encode-time (org-read-date-analyze - (replace-match "\\1 \\2" nil nil + (replace-match "\\6" nil nil org-read-date-final-answer) prompt-time (decode-time prompt-time)))) (t prompt-time))) -- 2.20.1 --=-=-=--