Function: org-agenda-compute-starting-span
org-agenda-compute-starting-span is a byte-compiled function defined
in org-agenda.el.gz.
Signature
(org-agenda-compute-starting-span SD SPAN &optional N)
Documentation
Compute starting date for agenda.
SPAN may be day, week, fortnight, month, year. The return value
is a cons cell with the starting date and the number of days,
so that the date SD will be in that range.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-agenda.el.gz
(defun org-agenda-compute-starting-span (sd span &optional n)
"Compute starting date for agenda.
SPAN may be `day', `week', `fortnight', `month', `year'. The return value
is a cons cell with the starting date and the number of days,
so that the date SD will be in that range."
(let* ((greg (calendar-gregorian-from-absolute sd))
;; (dg (nth 1 greg))
(mg (car greg))
(yg (nth 2 greg)))
(cond
((eq span 'day)
(when n
(setq sd (+ (calendar-absolute-from-gregorian
(list mg 1 yg))
n -1))))
((or (eq span 'week) (eq span 'fortnight))
(let* ((nt (calendar-day-of-week
(calendar-gregorian-from-absolute sd)))
(d (if org-agenda-start-on-weekday
(- nt org-agenda-start-on-weekday)
0))
y1)
(setq sd (- sd (+ (if (< d 0) 7 0) d)))
(when n
(require 'cal-iso)
(when (> n 99)
(setq y1 (org-small-year-to-year (/ n 100))
n (mod n 100)))
(setq sd
(calendar-iso-to-absolute
(list n 1
(or y1 (nth 2 (calendar-iso-from-absolute sd)))))))))
((eq span 'month)
(let (y1)
(when (and n (> n 99))
(setq y1 (org-small-year-to-year (/ n 100))
n (mod n 100)))
(setq sd (calendar-absolute-from-gregorian
(list (or n mg) 1 (or y1 yg))))))
((eq span 'year)
(setq sd (calendar-absolute-from-gregorian
(list 1 1 (or n yg))))))
sd))