emacs org-mode公式中的时间常量

时间:2014-10-08 07:54:00

标签: emacs org-mode org-table

在组织电子表格公式中有没有办法让时间不变?例如,我想有这样的事情:

@>$3=@>$5-'08:00:00'*vcount(@2..@-1)

计算我工作的时间比我必须多长时间:) @> $ 5是我工作时间和@ 2的总和。@ - 1是我已经工作的日子的行

非常感谢

1 个答案:

答案 0 :(得分:0)

它可以帮到你:

|     16:00 |  1 |     8:00 |
|  1d 16:00 |  3 |    16:00 |
|      8:00 |  3 |   -16:00 |
|     -8:00 |  2 | -1d 0:00 |
| -1d 16:00 | -6 |     8:00 |
|      8:00 |  1 |     0:00 |
#+TBLFM: $3='(calculate-hours $1 $2 8)

(defun calculate-hours (sumhours numdays hours-per-day)
  (if (string-match
       "\\(-*?\\)\\([0-9]*?\\)\\(?:d \\)*\\([0-9]+\\):\\([0-9]+\\)"
       sumhours)
      (let* ((input-sign (match-string 1 sumhours))
         (total-days
          (string-to-number (match-string 2 sumhours)))
         (total-hours
          (+ (* total-days 24)
         (string-to-number (match-string 3 sumhours))
         (/ (string-to-number (match-string 4 sumhours)) 60.0)))
         (forecast-hours
          (- (if (string-equal input-sign "-")
             (* -1 total-hours)
           total-hours)
         (* hours-per-day (string-to-number numdays))))
         (sign (if (>= (signum forecast-hours) 0) "" "-"))
         (forecast-hours (abs forecast-hours)))
    (if (>= forecast-hours 24)
        (let ((forecast-days
           (truncate (/ forecast-hours 24))))
          (concat
           sign
           (number-to-string forecast-days)
           "d "
           (number-to-string
        (- (/ (truncate (* forecast-hours 100)) 100) (* forecast-days 24)))
           ":00"))
      (concat
       sign
       (number-to-string
        (/ (truncate (* forecast-hours 100)) 100)) ":00"))) 0.0))