1

At work we do standups about what we did yesterday, I'm using datetree for my org-capture but the date recorded is by default today's date, I would like to change this so the date is of tomorrow instead of today.

Any pointers on how to change datetree default behavior.

4

If you look at the org-capture code, there's a :default-time property which by default uses the current time or the value of org-overriding-default-time. What the advice does is it shifts today's date by one day and assigns the new date to that variable, which is obviously a workaround so use it with caution:

(advice-add 'org-capture :around
            (lambda (oldfun &rest args)
              (let ((org-overriding-default-time
                     (funcall
                      (lambda ()
                        (let ((day (string-to-number (format-time-string "%d")))
                              (month (string-to-number (format-time-string "%m")))
                              (year (string-to-number (format-time-string "%Y"))))
                          (encode-time 1 1 0 (1+ day) month year))))))
                (apply oldfun args))))

You can also find or create an entry with a future date using the org-datetree-find-date-create function. Note that 86400 is the number of seconds in one day, so what the datetree-tomorrow function does is it adds that number to the current time to get tomorrow's date. Now you should be able to use this function in your template without having to advice org-capture.

(defun datetree-tomorrow ()
  (org-datetree-find-date-create
   (calendar-gregorian-from-absolute
    (time-to-days (time-add (current-time) (list 0 86400 0))))))

("key" "description" entry (file+function "path/to/file" datetree-tomorrow)
 "%?")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.