Function: org-datetree--find-create-group
org-datetree--find-create-group is a byte-compiled function defined in
org-datetree.el.gz.
Signature
(org-datetree--find-create-group D TIME-GROUPING &optional KEEP-RESTRICTION)
Documentation
Find or create an entry for date D.
If time-period is day, group entries by day. If time-period is month, then group entries by month.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-datetree.el.gz
(defun org-datetree--find-create-group
(d time-grouping &optional keep-restriction)
"Find or create an entry for date D.
If time-period is day, group entries by day.
If time-period is month, then group entries by month."
(setq-local org-datetree-base-level 1)
(save-restriction
(if (eq keep-restriction 'subtree-at-point)
(progn
(unless (org-at-heading-p) (error "Not at heading"))
(widen)
(org-narrow-to-subtree)
(setq-local org-datetree-base-level
(org-get-valid-level (org-current-level) 1)))
(unless keep-restriction (widen))
;; Support the old way of tree placement, using a property
(let ((prop (org-find-property "DATE_TREE")))
(when prop
(goto-char prop)
(setq-local org-datetree-base-level
(org-get-valid-level (org-current-level) 1))
(org-narrow-to-subtree))))
(goto-char (point-min))
(let ((year (calendar-extract-year d))
(month (calendar-extract-month d))
(day (calendar-extract-day d)))
(org-datetree--find-create
"\\([12][0-9]\\{3\\}\\)"
year nil nil nil t)
(org-datetree--find-create
"%d-\\([01][0-9]\\) \\w+"
year month nil nil t)
(when (eq time-grouping 'day)
(org-datetree--find-create
"%d-%02d-\\([0123][0-9]\\) \\w+"
year month day nil t)))))