From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id +NlgO/Jw5F8HCAAA0tVLHw (envelope-from ) for ; Thu, 24 Dec 2020 10:44:02 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id G70+N/Jw5F+5IwAAB5/wlQ (envelope-from ) for ; Thu, 24 Dec 2020 10:44:02 +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 6384D940276 for ; Thu, 24 Dec 2020 10:44:02 +0000 (UTC) Received: from localhost ([::1]:34398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ksO6C-0007fm-V5 for larch@yhetil.org; Thu, 24 Dec 2020 05:44:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ksO5L-0007fc-E6 for emacs-orgmode@gnu.org; Thu, 24 Dec 2020 05:43:07 -0500 Received: from wforward4-smtp.messagingengine.com ([64.147.123.34]:48797) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ksO5J-0006MH-4w for emacs-orgmode@gnu.org; Thu, 24 Dec 2020 05:43:06 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailforward.west.internal (Postfix) with ESMTP id 01BD256E for ; Thu, 24 Dec 2020 05:43:01 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 24 Dec 2020 05:43:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=L1BiCK/ulUzrQQ0DRN3kekUOEHugA 32RZoM9JCjl46s=; b=joBv34tlNeuov8DrAt4Y2ZVGMRzfB3VISh8qChKJI099J gzkrfYcO4fQsRGDPSJENeTrcYdlbfYmkeT4Nt3OHM6nB3x9ivi3Belp45wkYq633 ON2ctqS7+3q99jFUvQN83PFSVRCXc7raBtcAtnodMA0Rd4JHLhF4CXxPUM6oYbfM xwiGCmvlqUcOVo3stWTN6oMn8AJjHkTCKy08Qk5A5DUQLYvZqTEaDePkpnlIvFIA 8cbX6sGB5yWa2Bx7TeA73pwVxGo05K4f4CVDFKp/geMIpdny5fNQNJTpyAnSvAKb 6sHhQsAYON6B3VgkAdvgMeDI2Uy4eA3+Acy6N6Zew== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvddtledgudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkgggtsehttdertddttd dtnecuhfhrohhmpeftihgthhgrrhguucfnrgifrhgvnhgtvgcuoehrihgthhgrrhgurdhl rgifrhgvnhgtvgesuhhnihdqthhuvggsihhnghgvnhdruggvqeenucggtffrrghtthgvrh hnpeefheffvdekjeeuffegtedutdfhfeevtefgfffftdejudfhgedvuddugfejudfgtden ucffohhmrghinhepughirghrhidrohhrghenucfkphepiedvrddvudeirddvtddurdduie dvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhif lhesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Received: from aquinas (aftr-62-216-201-162.dynamic.mnet-online.de [62.216.201.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 1C35A108005B for ; Thu, 24 Dec 2020 05:43:01 -0500 (EST) Received: from rwl by aquinas with local (Exim 4.92) (envelope-from ) id 1ksO5C-0000Wo-Sn for emacs-orgmode@gnu.org; Thu, 24 Dec 2020 11:42:58 +0100 From: Richard Lawrence To: emacs-orgmode@gnu.org Subject: Bug: incorrect timestamps with :time-prompt and datetrees Date: Thu, 24 Dec 2020 11:42:58 +0100 Message-ID: <87h7obh4ct.fsf@aquinas> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: neutral client-ip=64.147.123.34; envelope-from=rwl@fastmail.com; helo=wforward4-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.25, RCVD_IN_DNSWL_LOW=-0.7, 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: -0.53 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=joBv34tl; 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: 6384D940276 X-Spam-Score: -0.53 X-Migadu-Scanner: scn0.migadu.com X-TUID: gSDBgh7dpx99 Hi all, I ran into a subtle bug yesterday. Basically, when using org-capture to capture - an entry into a datetree, - on a date other than today (using :time-prompt in org-capture-templates) - with a capture template that inserts a timestamp (%T) then I get incorrect results for either the timestamp or the location in the datetree, depending on how I enter the date. Here is a minimal working example: #+begin_src emacs-lisp (setq org-capture-templates `( ("d" "Diary") ("da" "Appointment/Event" entry (file+olp+datetree "/tmp/diary.org") "**** %^{Description}\n %T" :time-prompt t))) #+end_src Notice that the template contains %T, to expand to a timestamp with a time, and also that the capture target is a datetree and :time-prompt is true. My understanding is that this should both file the entry to the entered date in the datetree, and fill the %T template with a timestamp for the entered date (and time, if any). Here are the results from running a few captures with this setup on Dec 24 around 11AM. I tried various ways of scheduling an event on Dec 31 at 13:00; what I entered into the prompt of org-read-date is shown in the headline: #+begin_example * 2020 ** 2020-12 December *** 2020-12-24 Thursday **** Entered "31-12" <2020-12-31 Thu 11:06> This gets filed to the wrong day in the datetree, but the date in the timestamp is correct. The time is also correct (it's the current time, since no time was entered). **** Entered "31-12 13:00" <2020-12-31 Thu 13:00> This gets filed to the wrong day in the datetree, but the date and time in the timestamp are correct. *** 2020-12-31 Thursday **** Entered "12-31" <2020-12-31 Thu 00:00> This gets filed to the correct day in the datetree and the date in the timestamp is correct. The time is 00:00 because no time was entered. (Why isn't the time 11:06, though, like in the first example?) **** Entered "12-31 13:00" <2021-01-12 Tue 13:00> This is the most problematic case: it gets filed to the correct day in the datetree, but the date in the timestamp is incorrect! **** Entered "2020-12-31 13:00" <2020-12-31 Thu 13:00> If I enter the date in full ISO format, the location in the datetree and the timestamp are both correct. #+end_example Possibly relevant here is the value of calendar-date-style, which is 'american for me. I tested briefly with 'european but it did not make a difference for the "31-12" cases. This is org 9.4 running from maint (commit ab00524fc). I spent a while stepping through org-capture and org-read-date but haven't found the problem yet. I suspect this snippet from a cond form in the middle of org-capture-set-target-location: #+begin_src ((string-match "\\([^ ]+\\)-[^ ]+[ ]+\\(.*\\)" org-read-date-final-answer) ;; Replace any time range by its start. (apply #'encode-time (org-read-date-analyze ;; it looks to me like this is maybe sending the wrong value ;; into org-read-date-analyze: (replace-match "\\1 \\2" nil nil org-read-date-final-answer) #+end_src Will report here if I find out more exactly. Happy holidays, everyone! -- Best, Richard