]> git.eshelyaron.com Git - emacs.git/commitdiff
Port recent org-clock fix to POSIX time_t
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 28 Mar 2018 22:03:40 +0000 (15:03 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 28 Mar 2018 22:04:50 +0000 (15:04 -0700)
* lisp/org/org-clock.el (org-clock-special-range):
Don't assume support for time_t values less than 0, or less than
-2**31 for that matter (Bug#27736).

lisp/org/org-clock.el

index ff32e28d1e8a7fb5ffd59883e4da804b1eeddb14..9be0d5bc1ff9aab48c4d3e19087748d14cbf938b 100644 (file)
@@ -2239,8 +2239,18 @@ have priority."
     (let* ((start (pcase key
                    (`interactive (org-read-date nil t nil "Range start? "))
                     ;; In theory, all clocks started after the dawn of
-                    ;; humanity.
-                   (`untilnow (encode-time 0 0 0 0 0 -50000))
+                    ;; humanity.  However, the platform's clock
+                    ;; support might not go back that far.  Choose the
+                    ;; POSIX timestamp -2**41 (approximately 68,000
+                    ;; BCE) if that works, otherwise -2**31 (1901) if
+                    ;; that works, otherwise 0 (1970).  Going back
+                    ;; billions of years would loop forever on Mac OS
+                    ;; X 10.6 with Emacs 26 and earlier (Bug#27736).
+                   (`untilnow
+                     (let ((old 0))
+                       (dolist (older '((-32768 0) (-33554432 0)) old)
+                         (when (ignore-errors (decode-time older))
+                          (setq old older)))))
                    (_ (encode-time 0 m h d month y))))
           (end (pcase key
                  (`interactive (org-read-date nil t nil "Range end? "))