From 5a01b116a40fd87583cfb08d821b73cbe99f5a2d Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 26 Jul 2015 23:28:09 -0400 Subject: [PATCH] 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). --- lisp/org-timer.el | 7 +++++-- lisp/org.el | 10 ++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lisp/org-timer.el b/lisp/org-timer.el index b22db7bc6..3d1e5a5e6 100644 --- a/lisp/org-timer.el +++ b/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 diff --git a/lisp/org.el b/lisp/org.el index 4749e945b..c852a8015 100644 --- a/lisp/org.el +++ b/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))))