Function: calendar-day-number
calendar-day-number is a byte-compiled function defined in
calendar.el.gz.
Signature
(calendar-day-number DATE)
Documentation
Return the day number within the year of the date DATE.
For example, (calendar-day-number '(1 1 1987)) returns the value 1, while (calendar-day-number '(12 31 1980)) returns 366.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/calendar.el.gz
;; An explanation of the calculation can be found in PascAlgorithms by
;; Edward and Ruth Reingold, Scott-Foresman/Little, Brown, 1988.
(defsubst calendar-day-number (date)
"Return the day number within the year of the date DATE.
For example, (calendar-day-number \\='(1 1 1987)) returns the value 1,
while (calendar-day-number \\='(12 31 1980)) returns 366."
(let* ((month (calendar-extract-month date))
(day (calendar-extract-day date))
(year (calendar-extract-year date))
(day-of-year (+ day (* 31 (1- month)))))
(when (> month 2)
(setq day-of-year (- day-of-year (/ (+ 23 (* 4 month)) 10)))
(if (calendar-leap-year-p year)
(setq day-of-year (1+ day-of-year))))
day-of-year))