Calculate time range in org-mode table

二次信任 提交于 2020-02-24 04:40:20

问题


Given a table that has a column of time ranges e.g.:

|  <2015-10-02>--<2015-10-24> |
|  <2015-10-05>--<2015-10-20> |
....

how can I create a column showing the results of org-evalute-time-range?

If I attempt something like: #+TBLFM: $2='(org-evaluate-time-range $1)

the 2nd column is populated with

 Time difference inserted

in every row.

It would also be nice to generate the same result from two different columns with, say, start date and end date instead of creating one column of time ranges out of those two.


回答1:


If you have your date range split into 2 columns, a simple subtraction works and returns number of days:

| <2015-10-05>       | <2015-10-20> |        15 |
| <2013-10-02 08:30> | <2015-10-24> | 751.64583 |
#+TBLFM: $3=$2-$1

Using org-evaluate-time-range is also possible, and you get a nice formatted output:

| <2015-10-02>--<2015-10-24>           | 22 days                    |
| <2015-10-05>--<2015-10-20>           | 15 days                    |
| <2015-10-22 Thu 21:08>--<2015-08-01> | 82 days 21 hours 8 minutes |
#+TBLFM: $2='(org-evaluate-time-range)

Note that the only optional argument that org-evaluate-time-range accepts is a flag to indicate insertion of the result in the current buffer, which you don't want.

Now, how does this function (without arguments) get the correct time range when evaluated is a complete mystery to me; pure magic(!)



来源:https://stackoverflow.com/questions/33291580/calculate-time-range-in-org-mode-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!