Skip to content

Instantly share code, notes, and snippets.

@georgewsinger
Created May 13, 2019 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgewsinger/68dbcc33519378032d027dbd28014747 to your computer and use it in GitHub Desktop.
Save georgewsinger/68dbcc33519378032d027dbd28014747 to your computer and use it in GitHub Desktop.
sum-time-from-files.md
(defun sum-time-from-files (files start-date end-date)
  (let ((clocks
            (org-map-entries
            (lambda ()
              (progn
                (org-clock-sum start-date end-date)
                (if (= 1 (car (org-heading-components)))
                    (org-duration-to-minutes (or (org-entry-get nil "CLOCKSUM") "00:00"))
                    (org-duration-to-minutes "00:00"))
              ))
          nil ;(and (= 1 (car (org-heading-components))) (org-entry-get nil "CLOCKSUM"))
            files)))
    (org-minutes-to-clocksum-string (apply '+ clocks)
                                    )
))
@ndokos
Copy link

ndokos commented May 14, 2019

What;s the use of calling org-clock-sum since you are using neither its return value nor its side-effects?

Also, I think (car (org-heading-components)) is equivalent to (the simpler and clearer) (org-current-level).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment