summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-08-25 00:04:28 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-08-25 00:06:27 +0200
commitbae41a277eab4934df0a114de9d4fc164166f0eb (patch)
tree51a7bc79d1da54525a67c3fc66c4a86f47014416
parentb47de2506292b42b98143f1eb38d6d17fdc6f56d (diff)
downloadorg-mode-bae41a277eab4934df0a114de9d4fc164166f0eb.tar.gz
org-table: Fix sorting with times > 100 hours
* lisp/org-table.el (org-table-sort-lines): Fix regexp. Also test durations. * testing/lisp/test-org-table.el (test-org-table/sort-lines): Update tests. Add a new one.
-rw-r--r--lisp/org-table.el3
-rw-r--r--testing/lisp/test-org-table.el14
2 files changed, 12 insertions, 5 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el
index bd396e3..90401e5 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -1740,7 +1740,8 @@ function is being called interactively."
(cond ((string-match org-ts-regexp-both f)
(float-time
(org-time-string-to-time (match-string 0 f))))
- ((string-match "[0-9]\\{1,2\\}:[0-9]\\{2\\}" f)
+ ((org-duration-p f) (org-duration-to-minutes f))
+ ((string-match "\\<[0-9]+:[0-9]\\{2\\}\\>" f)
(org-duration-to-minutes (match-string 0 f)))
(t 0))))
((?f ?F)
diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el
index c5e34b5..63234e3 100644
--- a/testing/lisp/test-org-table.el
+++ b/testing/lisp/test-org-table.el
@@ -1668,15 +1668,21 @@ See also `test-org-table/copy-field'."
(buffer-string))))
;; Sort by time (HH:MM values)
(should
- (equal "| 1:00 |\n| 14:00 |\n| 17:00 |\n"
- (org-test-with-temp-text "| 14:00 |\n| 17:00 |\n| 1:00 |\n"
+ (equal "| 1:00 |\n| 17:00 |\n| 114:00 |\n"
+ (org-test-with-temp-text "| 114:00 |\n| 17:00 |\n| 1:00 |\n"
(org-table-sort-lines nil ?t)
(buffer-string))))
(should
- (equal "| 17:00 |\n| 14:00 |\n| 1:00 |\n"
- (org-test-with-temp-text "| 14:00 |\n| 17:00 |\n| 1:00 |\n"
+ (equal "| 114:00 |\n| 17:00 |\n| 1:00 |\n"
+ (org-test-with-temp-text "| 114:00 |\n| 17:00 |\n| 1:00 |\n"
(org-table-sort-lines nil ?T)
(buffer-string))))
+ ;; Sort by time (durations)
+ (should
+ (equal "| 1d 3:00 |\n| 28:00 |\n"
+ (org-test-with-temp-text "| 28:00 |\n| 1d 3:00 |\n"
+ (org-table-sort-lines nil ?t)
+ (buffer-string))))
;; Sort with custom functions.
(should
(equal "| 22 |\n| 15 |\n| 18 |\n"