]> code.delx.au - gnu-emacs/blobdiff - lisp/org/org-clock.el
Simplify now that float-time etc. are built-in
[gnu-emacs] / lisp / org / org-clock.el
index b386eb11652124eea165b5d3e7ce663ba21a7e0c..1ec17f4daa125a14de29dd3d02abe8258d1ee849 100644 (file)
@@ -1,6 +1,6 @@
 ;;; org-clock.el --- The time clocking code for Org-mode
 
-;; Copyright (C) 2004-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2016 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -658,8 +658,8 @@ If not, show simply the clocked time like 01:50."
 The time returned includes the time spent on this task in
 previous clocking intervals."
   (let ((currently-clocked-time
-        (floor (- (org-float-time)
-                  (org-float-time org-clock-start-time)) 60)))
+        (floor (- (float-time)
+                  (float-time org-clock-start-time)) 60)))
     (+ currently-clocked-time (or org-clock-total-time 0))))
 
 (defun org-clock-modify-effort-estimate (&optional value)
@@ -978,7 +978,7 @@ to be CLOCKED OUT."))))
                                   nil 45)))
                (and (not (memq char-pressed '(?i ?q))) char-pressed)))))
         (default
-          (floor (/ (org-float-time
+          (floor (/ (float-time
                      (time-subtract (current-time) last-valid)) 60)))
         (keep
          (and (memq ch '(?k ?K))
@@ -987,8 +987,8 @@ to be CLOCKED OUT."))))
          (and (memq ch '(?g ?G))
               (read-number "Got back how many minutes ago? " default)))
         (subtractp (memq ch '(?s ?S)))
-        (barely-started-p (< (- (org-float-time last-valid)
-                                (org-float-time (cdr clock))) 45))
+        (barely-started-p (< (- (float-time last-valid)
+                                (float-time (cdr clock))) 45))
         (start-over (and subtractp barely-started-p)))
     (cond
      ((memq ch '(?j ?J))
@@ -1047,8 +1047,8 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling
                        (lambda (clock)
                          (format
                           "Dangling clock started %d mins ago"
-                          (floor (- (org-float-time)
-                                    (org-float-time (cdr clock)))
+                          (floor (- (float-time)
+                                    (float-time (cdr clock)))
                                  60)))))
                   (or last-valid
                       (cdr clock)))))))))))
@@ -1057,7 +1057,7 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling
   "Return the current Emacs idle time in seconds, or nil if not idle."
   (let ((idle-time (current-idle-time)))
     (if idle-time
-       (org-float-time idle-time)
+       (float-time idle-time)
       0)))
 
 (defun org-mac-idle-seconds ()
@@ -1109,7 +1109,7 @@ so long."
           (function
            (lambda (clock)
              (format "Clocked in & idle for %.1f mins"
-                     (/ (org-float-time
+                     (/ (float-time
                          (time-subtract (current-time)
                                         org-clock-user-idle-start))
                         60.0))))
@@ -1271,9 +1271,9 @@ make this the default behavior.)"
                             (y-or-n-p
                              (format
                               "You stopped another clock %d mins ago; start this one from then? "
-                              (/ (- (org-float-time
+                              (/ (- (float-time
                                      (org-current-time org-clock-rounding-minutes t))
-                                    (org-float-time leftover)) 60)))
+                                    (float-time leftover)) 60)))
                             leftover)
                        start-time
                        (org-current-time org-clock-rounding-minutes t)))
@@ -1517,8 +1517,8 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
          (delete-region (point) (point-at-eol))
          (insert "--")
          (setq te (org-insert-time-stamp (or at-time now) 'with-hm 'inactive))
-         (setq s (- (org-float-time (apply 'encode-time (org-parse-time-string te)))
-                    (org-float-time (apply 'encode-time (org-parse-time-string ts))))
+         (setq s (- (float-time (apply 'encode-time (org-parse-time-string te)))
+                    (float-time (apply 'encode-time (org-parse-time-string ts))))
                h (floor (/ s 3600))
                s (- s (* 3600 h))
                m (floor (/ s 60))
@@ -1630,13 +1630,13 @@ Optional argument N tells to change by that many units."
        (let ((ts (if updatets1 ts2 ts1))
              (begts (if updatets1 begts1 begts2)))
          (setq tdiff
-               (subtract-time
+               (time-subtract
                 (org-time-string-to-time org-last-changed-timestamp)
                 (org-time-string-to-time ts)))
          (save-excursion
            (goto-char begts)
            (org-timestamp-change
-            (round (/ (org-float-time tdiff)
+            (round (/ (float-time tdiff)
                       (cond ((eq org-ts-what 'minute) 60)
                             ((eq org-ts-what 'hour) 3600)
                             ((eq org-ts-what 'day) (* 24 3600))
@@ -1739,8 +1739,8 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
          time)
      (if (stringp tstart) (setq tstart (org-time-string-to-seconds tstart)))
      (if (stringp tend) (setq tend (org-time-string-to-seconds tend)))
-     (if (consp tstart) (setq tstart (org-float-time tstart)))
-     (if (consp tend) (setq tend (org-float-time tend)))
+     (if (consp tstart) (setq tstart (float-time tstart)))
+     (if (consp tend) (setq tend (float-time tend)))
      (remove-text-properties (point-min) (point-max)
                             `(,(or propname :org-clock-minutes) t
                               :org-clock-force-headline-inclusion t))
@@ -1752,9 +1752,9 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
           ;; Two time stamps
           (setq ts (match-string 2)
                 te (match-string 3)
-                ts (org-float-time
+                ts (float-time
                     (apply 'encode-time (org-parse-time-string ts)))
-                te (org-float-time
+                te (float-time
                     (apply 'encode-time (org-parse-time-string te)))
                 ts (if tstart (max ts tstart) ts)
                 te (if tend (min te tend) te)
@@ -1771,10 +1771,10 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
                      (equal (marker-position org-clock-hd-marker) (point))
                      tstart
                      tend
-                     (>= (org-float-time org-clock-start-time) tstart)
-                     (<= (org-float-time org-clock-start-time) tend))
-            (let ((time (floor (- (org-float-time)
-                                  (org-float-time org-clock-start-time)) 60)))
+                     (>= (float-time org-clock-start-time) tstart)
+                     (<= (float-time org-clock-start-time) tend))
+            (let ((time (floor (- (float-time)
+                                  (float-time org-clock-start-time)) 60)))
               (setq t1 (+ t1 time))))
           (let* ((headline-forced
                   (get-text-property (point)
@@ -2584,17 +2584,17 @@ from the dynamic block definition."
      ((numberp ts)
       ;; If ts is a number, it's an absolute day number from org-agenda.
       (destructuring-bind (month day year) (calendar-gregorian-from-absolute ts)
-       (setq ts (org-float-time (encode-time 0 0 0 day month year)))))
+       (setq ts (float-time (encode-time 0 0 0 day month year)))))
      (ts
-      (setq ts (org-float-time
+      (setq ts (float-time
                (apply 'encode-time (org-parse-time-string ts))))))
     (cond
      ((numberp te)
       ;; Likewise for te.
       (destructuring-bind (month day year) (calendar-gregorian-from-absolute te)
-       (setq te (org-float-time (encode-time 0 0 0 day month year)))))
+       (setq te (float-time (encode-time 0 0 0 day month year)))))
      (te
-      (setq te (org-float-time
+      (setq te (float-time
                (apply 'encode-time (org-parse-time-string te))))))
     (setq tsb
          (if (eq step0 'week)
@@ -2788,9 +2788,9 @@ Otherwise, return nil."
          (end-of-line 1)
          (setq ts (match-string 1)
                te (match-string 3))
-         (setq s (- (org-float-time
+         (setq s (- (float-time
                      (apply 'encode-time (org-parse-time-string te)))
-                    (org-float-time
+                    (float-time
                      (apply 'encode-time (org-parse-time-string ts))))
                neg (< s 0)
                s (abs s)