summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-06-14 11:00:01 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-06-14 11:00:01 +0200
commitb47920ed208119a0a9de307b1839a4aed54572ef (patch)
tree73b1296b3faa1b4499aab2135ba11fade7cdfba2
parent2040b613914cb4153efee3d11650777a4c759d33 (diff)
downloadorg-mode-b47920ed208119a0a9de307b1839a4aed54572ef.tar.gz
org-colview: Fix failing test
* lisp/org.el (org-parse-time-string): Allow to specify zone as an optional argument. * lisp/org-colview.el (org-columns--age-to-seconds): Apply change above. * testing/lisp/test-org-colview.el (test-org-colview/columns-summary): Update tests.
-rw-r--r--lisp/org-colview.el2
-rw-r--r--lisp/org.el16
-rw-r--r--testing/lisp/test-org-colview.el10
3 files changed, 17 insertions, 11 deletions
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 2f25f56..ac8f36a 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -1085,7 +1085,7 @@ as days/hours/minutes/seconds."
((string-match-p org-ts-regexp s)
(floor
(- org-columns--time
- (float-time (apply #'encode-time (org-parse-time-string s))))))
+ (float-time (apply #'encode-time (org-parse-time-string s nil t))))))
;; Match own output for computations in upper levels.
((string-match "\\([0-9]+\\)d \\([0-9]+\\)h \\([0-9]+\\)m \\([0-9]+\\)s" s)
(+ (* 86400 (string-to-number (match-string 1 s)))
diff --git a/lisp/org.el b/lisp/org.el
index 2b2b863..f4d06bc 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17937,11 +17937,17 @@ day number."
(list (nth 4 d) (nth 3 d) (nth 5 d))))
((listp d) (list (nth 4 d) (nth 3 d) (nth 5 d)))))
-(defun org-parse-time-string (s &optional nodefault)
+(defun org-parse-time-string (s &optional nodefault zone)
"Parse the standard Org time string.
+
This should be a lot faster than the normal `parse-time-string'.
-If time is not given, defaults to 0:00. However, with optional NODEFAULT,
-hour and minute fields will be nil if not given."
+
+If time is not given, defaults to 0:00. However, with optional
+NODEFAULT, hour and minute fields will be nil if not given.
+
+The optional ZONE is omitted or nil for Emacs local time, t for
+Universal Time, ‘wall’ for system wall clock time, or a string as
+in the TZ environment variable."
(cond ((string-match org-ts-regexp0 s)
(list 0
(when (or (match-beginning 8) (not nodefault))
@@ -17951,9 +17957,9 @@ hour and minute fields will be nil if not given."
(string-to-number (match-string 4 s))
(string-to-number (match-string 3 s))
(string-to-number (match-string 2 s))
- nil nil nil))
+ nil nil zone))
((string-match "^<[^>]+>$" s)
- (decode-time (seconds-to-time (org-matcher-time s))))
+ (decode-time (seconds-to-time (org-matcher-time s)) zone))
(t (error "Not a standard Org time string: %s" s))))
(defun org-timestamp-up (&optional arg)
diff --git a/testing/lisp/test-org-colview.el b/testing/lisp/test-org-colview.el
index 7bf385a..3e922bc 100644
--- a/testing/lisp/test-org-colview.el
+++ b/testing/lisp/test-org-colview.el
@@ -513,7 +513,7 @@
(cl-letf (((symbol-function 'current-time)
(lambda ()
(apply #'encode-time
- (org-parse-time-string "<2014-03-04 Tue>")))))
+ (org-parse-time-string "<2014-03-04 Tue>" nil t)))))
(org-test-with-temp-text
"* H
** S1
@@ -528,11 +528,11 @@
(get-char-property (point) 'org-columns-value-modified)))))
(should
(equal
- "705d 01h 0m 0s"
+ "705d 00h 0m 0s"
(cl-letf (((symbol-function 'current-time)
(lambda ()
(apply #'encode-time
- (org-parse-time-string "<2014-03-04 Tue>")))))
+ (org-parse-time-string "<2014-03-04 Tue>" nil t)))))
(org-test-with-temp-text
"* H
** S1
@@ -547,11 +547,11 @@
(get-char-property (point) 'org-columns-value-modified)))))
(should
(equal
- "352d 12h 30m 0s"
+ "352d 12h 0m 0s"
(cl-letf (((symbol-function 'current-time)
(lambda ()
(apply #'encode-time
- (org-parse-time-string "<2014-03-04 Tue>")))))
+ (org-parse-time-string "<2014-03-04 Tue>" nil t)))))
(org-test-with-temp-text
"* H
** S1