emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug#54764: encode-time: make DST and TIMEZONE fields of the list arg


From: Max Nikulin
Subject: Re: bug#54764: encode-time: make DST and TIMEZONE fields of the list argument optional ones
Date: Wed, 13 Apr 2022 22:12:37 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0

On 09/04/2022 14:52, Paul Eggert wrote:
0001-Improve-Org-usage-of-timestamps.patch

From 094345e10ad45e06f7b32e2f8017592210f43463 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 9 Apr 2022 00:17:09 -0700
Subject: [PATCH] Improve Org usage of timestamps
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The main thing is to follow the (encode-time X) convention where
X’s DST component of nil means standard time, -1 means unknown.

I am marking this thread as a patch for https://updates.orgmode.org
"Use -1 (guess) instead of nil (no) for DST value in encode-time arguments"

From my point of view the changes quoted below are most important ones in the patch and they should be committed to the Org repository. Preferably a unit test for time zones should be added for `org-parse-time-string'.

I omitted changes to improve code style, they should be applied as well, I just consider them as having less priority.

I am in doubt concerning `org-encode-time-1' part.

diff --git a/lisp/org/ol.el b/lisp/org/ol.el
index a03d85f618..fe6e97e928 100644
--- a/lisp/org/ol.el
+++ b/lisp/org/ol.el
@@ -1575,9 +1575,7 @@ org-store-link
          (setq link
                (format-time-string
                 (car org-time-stamp-formats)
-                (apply 'encode-time
-                       (list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
-                             nil nil nil))))
+                (encode-time 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd))))
          (org-link-store-props :type "calendar" :date cd)))
((eq major-mode 'w3-mode)
It allows to avoid a pitfall with nil as DST value.

diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el
index b10725bd52..0916da89ac 100644
--- a/lisp/org/org-macs.el
+++ b/lisp/org/org-macs.el
@@ -1242,7 +1242,7 @@ org-parse-time-string
        (string-to-number (match-string 4 s))
        (string-to-number (match-string 3 s))
        (string-to-number (match-string 2 s))
-       nil nil nil))
+       nil -1 nil))

It definitely must be changed in the Org code.

diff --git a/lisp/org/org.el b/lisp/org/org.el
index d656a51591..1bceb0f53a 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -14334,7 +14334,7 @@ org-read-date-analyze
         (setq year (nth 5 org-defdecode))
         (setq org-read-date-analyze-forced-year t))))
     (setq org-read-date-analyze-futurep futurep)
-    (list second minute hour day month year)))
+    (list second minute hour day month year nil -1 nil)))
(defvar parse-time-weekdays)
 (defun org-read-date-get-relative (s today default)

Unsure concerning adding extra elements. I would prefer change of `encode-time' in future and a compatibility macro as in the following for a while.

Max Nikulin [DRAFT][PATCH] org-encode-time compatibility and convenience helper. Mon, 11 Apr 2022 22:22:48 +0700.
7f4ea652-7d22-fb61-f873-5e92f078c9e6@gmail.com">https://lsit.orgmode.org/7f4ea652-7d22-fb61-f873-5e92f078c9e6@gmail.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]