Function: icalendar-date/time-weekno

icalendar-date/time-weekno is a byte-compiled function defined in icalendar-utils.el.gz.

Signature

(icalendar-date/time-weekno DT &optional WEEKSTART)

Documentation

Return DT's ISO week number.

DT may be either an icalendar-date or an icalendar-date-time. WEEKSTART defaults to 1; it represents the day which starts the week, and should be an integer between 0 (= Sunday) and 6 (= Saturday).

Other relevant functions are documented in the icalendar group.

Shortdoc

;; icalendar
(icalendar-date/time-weekno '(12 11 2024))
    => 50
  (icalendar-date/time-weekno '(0 0 10 11 12 2024 3 nil 3600))
    => 50

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar-utils.el.gz
(defun ical:date/time-weekno (dt &optional weekstart)
  "Return DT's ISO week number.
DT may be either an `icalendar-date' or an `icalendar-date-time'.
WEEKSTART defaults to 1; it represents the day which starts the week,
and should be an integer between 0 (= Sunday) and 6 (= Saturday)."
  ;; TODO: Add support for weekstart.
  ;; calendar-iso-from-absolute doesn't support this yet.
  (when (and weekstart (not (= weekstart 1)))
    (error "Support for WEEKSTART other than 1 (=Monday) not implemented yet"))
  (let* ((gdate (ical:date/time-to-date dt))
         (isodate (calendar-iso-from-absolute
                   (calendar-absolute-from-gregorian gdate)))
         (weekno (car isodate)))
    weekno))