Browse Source

Pass current-time as optional arg for tests

* lisp/org.el (org-read-date-analyze):
* lisp/org-timer.el (org-timer-seconds): Explicitly pass current-time as
  optional time argument and explain reason in comment.

This reverts some changes from 91ab6c4 ("Backport commit 123ddec from
Emacs master branch", 2014-10-28).
Kyle Meyer 9 years ago
parent
commit
5a01b116a4
2 changed files with 13 additions and 4 deletions
  1. 5 2
      lisp/org-timer.el
  2. 8 2
      lisp/org.el

+ 5 - 2
lisp/org-timer.el

@@ -193,10 +193,13 @@ it in the buffer."
 
 (defvar org-timer-timer-is-countdown nil)
 (defun org-timer-seconds ()
+  ;; Pass `current-time' result to `org-float-time'
+  ;; (instead of calling without arguments) so that only
+  ;; `current-time' has to be overriden in tests.
   (if org-timer-timer-is-countdown
       (- (org-float-time org-timer-start-time)
-	 (org-float-time))
-    (- (org-float-time org-timer-pause-time)
+	 (org-float-time (current-time)))
+    (- (org-float-time (or org-timer-pause-time (current-time)))
        (org-float-time org-timer-start-time))))
 
 ;;;###autoload

+ 8 - 2
lisp/org.el

@@ -16494,7 +16494,10 @@ user."
 (defun org-read-date-analyze (ans org-def org-defdecode)
   "Analyze the combined answer of the date prompt."
   ;; FIXME: cleanup and comment
-  (let ((nowdecode (decode-time))
+  ;; Pass `current-time' result to `decode-time' (instead of calling
+  ;; without arguments) so that only `current-time' has to be
+  ;; overriden in tests.
+  (let ((nowdecode (decode-time (current-time)))
 	delta deltan deltaw deltadef year month day
 	hour minute second wday pm h2 m2 tl wday1
 	iso-year iso-weekday iso-week iso-year iso-date futurep kill-year)
@@ -16652,7 +16655,10 @@ user."
      (deltan
       (setq futurep nil)
       (unless deltadef
-	(let ((now (decode-time)))
+	;; Pass `current-time' result to `decode-time' (instead of
+	;; calling without arguments) so that only `current-time' has
+	;; to be overriden in tests.
+	(let ((now (decode-time (current-time))))
 	  (setq day (nth 3 now) month (nth 4 now) year (nth 5 now))))
       (cond ((member deltaw '("d" "")) (setq day (+ day deltan)))
 	    ((equal deltaw "w") (setq day (+ day (* 7 deltan))))