diff options
author | Bastien Guerry <bzg@altern.org> | 2012-12-20 01:36:05 +0100 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2012-12-20 01:36:05 +0100 |
commit | beeb9168dd64d33549ccb54c2931eb0642486faa (patch) | |
tree | f13c8fa3c348c1a05c5d04d717845a67f4913bb9 | |
parent | fcd269baa872b73cc635059b8ec2eb23d7c24657 (diff) | |
download | org-mode-beeb9168dd64d33549ccb54c2931eb0642486faa.tar.gz |
org-table.el: Handle localized time-stamps in formulas evaluation
* org-table.el (org-table-eval-formula): Handle localized
time-stamps by internally converting them to english during
formulas evaluation.
Thanks to Viktor Rosenfeld for suggesting this.
-rw-r--r-- | lisp/org-table.el | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el index acad0bb..9d1c68a 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -2647,8 +2647,18 @@ not overwrite the stored one." duration-output-format) ev)) (or (fboundp 'calc-eval) (error "Calc does not seem to be installed, and is needed to evaluate the formula")) - ;; "Inactivate" time-stamps so that Calc can handle them + ;; Use <...> time-stamps so that Calc can handle them (setq form (replace-regexp-in-string org-ts-regexp3 "<\\1>" form)) + ;; I18n-ize local time-stamps by setting (system-time-locale "C") + (when (string-match org-ts-regexp2 form) + (let* ((ts (match-string 0 form)) + (tsp (apply 'encode-time (save-match-data (org-parse-time-string ts)))) + (system-time-locale "C") + (tf (or (and (save-match-data (string-match "[0-9]\\{1,2\\}:[0-9]\\{2\\}" ts)) + (cdr org-time-stamp-formats)) + (car org-time-stamp-formats)))) + (setq form (replace-match (format-time-string tf tsp) t t form)))) + (setq ev (if (and duration (string-match "^[0-9]+:[0-9]+\\(?::[0-9]+\\)?$" form)) form (calc-eval (cons form org-tbl-calc-modes) (if numbers 'num))) |