emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/org a4105d0942 05/12: Use higher level helpers instead


From: ELPA Syncer
Subject: [elpa] externals/org a4105d0942 05/12: Use higher level helpers instead of `encode-time'
Date: Sun, 17 Jul 2022 04:57:50 -0400 (EDT)

branch: externals/org
commit a4105d0942d8728c689040baffa32d1273750fd6
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Ihor Radchenko <yantar92@gmail.com>

    Use higher level helpers instead of `encode-time'
    
    * lisp/org-clock.el (org-clock-sum)
    (org-clock-update-time-maybe):
    Prefer org-time-string-to-seconds to doing it by hand.
    * lisp/org-macs.el (org-2ft):
    Prefer org-time-string-to-seconds to doing it by hand.
    * lisp/org-table.el (org-table-eval-formula):
    Prefer org-time-string-to-time to doing it by hand.
    
    Max Nikulin:
    A larger patch "Improve Org usage of timestamps" was suggested in
    https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54764#10
    
    Only cosmetic changes are selected for this patch.
---
 lisp/org-clock.el | 17 ++++++-----------
 lisp/org-macs.el  |  2 +-
 lisp/org-table.el |  3 +--
 3 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index e0b2d3ce69..577baaa838 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1914,13 +1914,10 @@ PROPNAME lets you set a custom text property instead of 
:org-clock-minutes."
          (cond
           ((match-end 2)
            ;; Two time stamps.
-           (let* ((ts (float-time
-                       (apply #'encode-time
-                              (save-match-data
-                                (org-parse-time-string (match-string 2))))))
-                  (te (float-time
-                       (apply #'encode-time
-                              (org-parse-time-string (match-string 3)))))
+           (let* ((ss (match-string 2))
+                  (se (match-string 3))
+                  (ts (org-time-string-to-seconds ss))
+                  (te (org-time-string-to-seconds se))
                   (dt (- (if tend (min te tend) te)
                          (if tstart (max ts tstart) ts))))
              (when (> dt 0) (cl-incf t1 (floor dt 60)))))
@@ -3052,10 +3049,8 @@ Otherwise, return nil."
          (end-of-line 1)
          (setq ts (match-string 1)
                te (match-string 3))
-         (setq s (- (float-time
-                     (apply #'encode-time (org-parse-time-string te)))
-                    (float-time
-                     (apply #'encode-time (org-parse-time-string ts))))
+         (setq s (- (org-time-string-to-seconds te)
+                    (org-time-string-to-seconds ts))
                neg (< s 0)
                s (abs s)
                h (floor (/ s 3600))
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index b6f1a7fdfc..b848987765 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -1358,7 +1358,7 @@ nil, just return 0."
    ((numberp s) s)
    ((stringp s)
     (condition-case nil
-       (float-time (apply #'encode-time (org-parse-time-string s)))
+       (org-time-string-to-seconds s)
       (error 0)))
    (t 0)))
 
diff --git a/lisp/org-table.el b/lisp/org-table.el
index e84c2090fb..e9d6c5a9fc 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -2607,8 +2607,7 @@ location of point."
                     (format-time-string
                      (org-time-stamp-format
                       (string-match-p "[0-9]\\{1,2\\}:[0-9]\\{2\\}" ts))
-                     (apply #'encode-time
-                            (save-match-data (org-parse-time-string ts))))))
+                     (save-match-data (org-time-string-to-time ts)))))
                 form t t))
 
          (setq ev (if (and duration (string-match 
"^[0-9]+:[0-9]+\\(?::[0-9]+\\)?$" form))



reply via email to

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