summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2012-05-01 19:19:06 +0200
committerBastien Guerry <bzg@altern.org>2012-05-01 19:19:06 +0200
commit0dbe17b8e001b7df079ed4325057f3abfb191138 (patch)
tree484f8f093d6af002c575d571fa1f33179550108a
parent9fa0b5e794c92aa1c7ad03217fb412be8cd68bfb (diff)
downloadorg-mode-0dbe17b8e001b7df079ed4325057f3abfb191138.tar.gz
org-table.el: Fix bug about handling a negative duration value.
* org-table.el (org-table-time-seconds-to-string): Fix bug about handling a negative duration value.
-rw-r--r--lisp/org-table.el21
1 files changed, 12 insertions, 9 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el
index f1bb0ac..e02062a 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -3310,15 +3310,18 @@ If S is a string representing a number, keep this number."
"Convert a number of seconds to a time string.
If OUTPUT-FORMAT is non-nil, return a number of days, hours,
minutes or seconds."
- (cond ((eq output-format 'days)
- (format "%.3f" (/ (float secs) 86400)))
- ((eq output-format 'hours)
- (format "%.2f" (/ (float secs) 3600)))
- ((eq output-format 'minutes)
- (format "%.1f" (/ (float secs) 60)))
- ((eq output-format 'seconds)
- (format "%d" secs))
- (t (org-format-seconds "%.2h:%.2m:%.2s" secs))))
+ (let* ((secs0 (abs secs))
+ (res
+ (cond ((eq output-format 'days)
+ (format "%.3f" (/ (float secs0) 86400)))
+ ((eq output-format 'hours)
+ (format "%.2f" (/ (float secs0) 3600)))
+ ((eq output-format 'minutes)
+ (format "%.1f" (/ (float secs0) 60)))
+ ((eq output-format 'seconds)
+ (format "%d" secs0))
+ (t (org-format-seconds "%.2h:%.2m:%.2s" secs0)))))
+ (if (< secs 0) (concat "-" res) res)))
(defun org-table-fedit-convert-buffer (function)
"Convert all references in this buffer, using FUNCTION."