emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* bug#54731: Please, revert part of dd0727e1ec1 related to Org mode (`encode-time')
@ 2022-04-05 16:43 Max Nikulin
  2022-04-06  0:56 ` Paul Eggert
  0 siblings, 1 reply; 2+ messages in thread
From: Max Nikulin @ 2022-04-05 16:43 UTC (permalink / raw)
  To: 54731; +Cc: eggert, emacs-orgmode

Recently a bug with daylight saving time has been reported to the Org 
mode mail list:

https://list.orgmode.org/PAXPR06MB7760238F410CBE3203F78EE0C61E9@PAXPR06MB7760.eurprd06.prod.outlook.com
Ignacio Casso. [BUG] org-agenda thinks timestamps after 23:00 correspond 
to the next day. Tue, 29 Mar 2022 15:09:10 +0200.

It can be reproduced only with the Org version bundled with Emacs-29. 
The code from the Org git repository works correctly. Due to Emacs 
commit dd0727e1ec1
    Paul Eggert Thu Dec 16 09:40:21 2021 -0800 encode-time simplifications
code of Org in the Emacs and the Org repositories diverged. Changes can 
not be just committed to Org since Org as a standalone package is 
compatible with Emacs-26 and even still with Emacs-25 where new style of 
`encode-time' arguments are not supported.

Moreover daylight saving time flag is ignored when timestamp components 
are passed as separate arguments and some Org code uses nil value (no 
DST) instead of -1 (ignore DST).

Even within Emacs both old and new calling styles of `encode-time' are 
used, so partial revert of the change does not reduce code consistency 
significantly enough.

On the Org side it is necessary to update at least the 
`org-parse-time-string' function and to introduce a compatibility 
wrapper that will use old calling convention when running under old 
Emacs versions. Such changes should finally land in the Emacs repository 
as well.

Please, revert changes from dd0727e1ec1 related to Org to fix the 
daylight saving time and to mitigate merge conflicts during porting of 
future fixes in Org.

Notice, this bug is namely for Emacs, not for Org mode as debbugs packages.




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: bug#54731: Please, revert part of dd0727e1ec1 related to Org mode (`encode-time')
  2022-04-05 16:43 bug#54731: Please, revert part of dd0727e1ec1 related to Org mode (`encode-time') Max Nikulin
@ 2022-04-06  0:56 ` Paul Eggert
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Eggert @ 2022-04-06  0:56 UTC (permalink / raw)
  To: Max Nikulin, 54731; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 464 bytes --]

On 4/5/22 09:43, Max Nikulin wrote:

> Please, revert changes from dd0727e1ec1 related to Org to fix the 
> daylight saving time and to mitigate merge conflicts during porting of 
> future fixes in Org.

Thanks for mentioning the problem. I installed the attached, which I 
hope suffices.

This patch does keep two of the Org-related parts of dd0727e1ec1; these 
parts should work OK with Emacs 25 and so can be merged into Org before 
it starts assuming Emacs 27.

[-- Attachment #2: 0001-Port-Org-encode-time-usage-back-to-Emacs-25.patch --]
[-- Type: text/x-patch, Size: 6628 bytes --]

From 9e07ec56c7e58ee1eb5598dfdd1b772a690daa24 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 5 Apr 2022 17:48:05 -0700
Subject: [PATCH] Port Org encode-time usage back to Emacs 25
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org/ol.el (org-store-link):
* lisp/org/org-clock.el (org-clock-sum)
(org-clock-update-time-maybe):
* lisp/org/org-colview.el (org-colview-construct-allowed-dates):
* lisp/org/org-macro.el (org-macro--vc-modified-time):
* lisp/org/org-macs.el (org-2ft, org-matcher-time):
* lisp/org/org-table.el (org-table-eval-formula):
* lisp/org/org.el (org-read-date, org-display-custom-time)
(org-time-string-to-time, org-timestamp-change):
Don’t assume Emacs 27 encode-time, since standalone Org still
works with Emacs 25 and it’s easier if we minimize differences
from standalone Org.  Problem reported by Max Nikulin (Bug#54731).
This reverts much of 2021-12-16T17:40:21Z!eggert@cs.ucla.edu.
---
 lisp/org/ol.el          | 2 +-
 lisp/org/org-clock.el   | 8 ++++----
 lisp/org/org-colview.el | 2 +-
 lisp/org/org-macro.el   | 2 +-
 lisp/org/org-macs.el    | 4 ++--
 lisp/org/org-table.el   | 2 +-
 lisp/org/org.el         | 8 ++++----
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/lisp/org/ol.el b/lisp/org/ol.el
index 905e491f4a..a03d85f618 100644
--- a/lisp/org/ol.el
+++ b/lisp/org/ol.el
@@ -1575,7 +1575,7 @@ org-store-link
 	  (setq link
 		(format-time-string
 		 (car org-time-stamp-formats)
-		 (encode-time
+		 (apply 'encode-time
 			(list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
 			      nil nil nil))))
 	  (org-link-store-props :type "calendar" :date cd)))
diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el
index dce5d9d4c0..7395669109 100644
--- a/lisp/org/org-clock.el
+++ b/lisp/org/org-clock.el
@@ -1904,11 +1904,11 @@ org-clock-sum
 	   ((match-end 2)
 	    ;; Two time stamps.
 	    (let* ((ts (float-time
-			(encode-time
+			(apply #'encode-time
 			       (save-match-data
 				 (org-parse-time-string (match-string 2))))))
 		   (te (float-time
-			(encode-time
+			(apply #'encode-time
 			       (org-parse-time-string (match-string 3)))))
 		   (dt (- (if tend (min te tend) te)
 			  (if tstart (max ts tstart) ts))))
@@ -3042,9 +3042,9 @@ org-clock-update-time-maybe
 	  (setq ts (match-string 1)
 		te (match-string 3))
 	  (setq s (- (float-time
-		      (encode-time (org-parse-time-string te)))
+		      (apply #'encode-time (org-parse-time-string te)))
 		     (float-time
-		      (encode-time (org-parse-time-string ts))))
+		      (apply #'encode-time (org-parse-time-string ts))))
 		neg (< s 0)
 		s (abs s)
 		h (floor (/ s 3600))
diff --git a/lisp/org/org-colview.el b/lisp/org/org-colview.el
index 371889432d..829fcbbe3f 100644
--- a/lisp/org/org-colview.el
+++ b/lisp/org/org-colview.el
@@ -782,7 +782,7 @@ org-colview-construct-allowed-dates
       (setq time-after (copy-sequence time))
       (setf (nth 3 time-before) (1- (nth 3 time)))
       (setf (nth 3 time-after) (1+ (nth 3 time)))
-      (mapcar (lambda (x) (format-time-string fmt (encode-time x)))
+      (mapcar (lambda (x) (format-time-string fmt (apply #'encode-time x)))
 	      (list time-before time time-after)))))
 
 (defun org-columns-open-link (&optional arg)
diff --git a/lisp/org/org-macro.el b/lisp/org/org-macro.el
index bb8a95065b..0921f3aa27 100644
--- a/lisp/org/org-macro.el
+++ b/lisp/org/org-macro.el
@@ -378,7 +378,7 @@ org-macro--vc-modified-time
 				  (buffer-substring
 				   (point) (line-end-position)))))
 		       (when (cl-some #'identity time)
-			 (setq date (encode-time time))))))))
+			 (setq date (apply #'encode-time time))))))))
 	      (let ((proc (get-buffer-process buf)))
 		(while (and proc (accept-process-output proc .5 nil t)))))
 	  (kill-buffer buf))
diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el
index 6f038f026b..b10725bd52 100644
--- a/lisp/org/org-macs.el
+++ b/lisp/org/org-macs.el
@@ -1185,7 +1185,7 @@ org-2ft
    ((numberp s) s)
    ((stringp s)
     (condition-case nil
-	(float-time (encode-time (org-parse-time-string s)))
+	(float-time (apply #'encode-time (org-parse-time-string s)))
       (error 0)))
    (t 0)))
 
@@ -1252,7 +1252,7 @@ org-matcher-time
 \"<tomorrow>\", and \"<yesterday>\".
 
 Return 0. if S is not recognized as a valid value."
-  (let ((today (float-time (encode-time
+  (let ((today (float-time (apply #'encode-time
 				  (append '(0 0 0) (nthcdr 3 (decode-time)))))))
     (save-match-data
       (cond
diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el
index 58707eae44..c4daed1665 100644
--- a/lisp/org/org-table.el
+++ b/lisp/org/org-table.el
@@ -2606,7 +2606,7 @@ org-table-eval-formula
 		     (format-time-string
 		      (org-time-stamp-format
 		       (string-match-p "[0-9]\\{1,2\\}:[0-9]\\{2\\}" ts))
-		      (encode-time
+		      (apply #'encode-time
 			     (save-match-data (org-parse-time-string ts))))))
 		 form t t))
 
diff --git a/lisp/org/org.el b/lisp/org/org.el
index 67c8f1cedf..d656a51591 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -13986,7 +13986,7 @@ org-read-date
     (when (< (nth 2 org-defdecode) org-extend-today-until)
       (setf (nth 2 org-defdecode) -1)
       (setf (nth 1 org-defdecode) 59)
-      (setq org-def (encode-time org-defdecode))
+      (setq org-def (apply #'encode-time org-defdecode))
       (setq org-defdecode (decode-time org-def)))
     (let* ((timestr (format-time-string
 		     (if org-with-time "%Y-%m-%d %H:%M" "%Y-%m-%d")
@@ -14470,7 +14470,7 @@ org-display-custom-time
 	  time (org-fix-decoded-time t1)
 	  str (org-add-props
 		  (format-time-string
-		   (substring tf 1 -1) (encode-time time))
+		   (substring tf 1 -1) (apply 'encode-time time))
 		  nil 'mouse-face 'highlight))
     (put-text-property beg end 'display str)))
 
@@ -14725,7 +14725,7 @@ org-make-tdiff-string
 
 (defun org-time-string-to-time (s)
   "Convert timestamp string S into internal time."
-  (encode-time (org-parse-time-string s)))
+  (apply #'encode-time (org-parse-time-string s)))
 
 (defun org-time-string-to-seconds (s)
   "Convert a timestamp string S into a number of seconds."
@@ -15155,7 +15155,7 @@ org-timestamp-change
 	  (setcar time0 (or (car time0) 0))
 	  (setcar (nthcdr 1 time0) (or (nth 1 time0) 0))
 	  (setcar (nthcdr 2 time0) (or (nth 2 time0) 0))
-	  (setq time (encode-time time0))))
+	  (setq time (apply 'encode-time time0))))
       ;; Insert the new time-stamp, and ensure point stays in the same
       ;; category as before (i.e. not after the last position in that
       ;; category).
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-06  0:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-05 16:43 bug#54731: Please, revert part of dd0727e1ec1 related to Org mode (`encode-time') Max Nikulin
2022-04-06  0:56 ` Paul Eggert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).