Function: calendar-cursor-to-date
calendar-cursor-to-date is a byte-compiled function defined in
calendar.el.gz.
Signature
(calendar-cursor-to-date &optional ERROR EVENT)
Documentation
Return a list (month day year) of current cursor position.
If cursor is not on a specific date, signals an error if optional parameter ERROR is non-nil, otherwise just returns nil. If EVENT is non-nil, it's an event indicating the buffer position to use instead of point.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/calendar.el.gz
(defun calendar-cursor-to-date (&optional error event)
"Return a list (month day year) of current cursor position.
If cursor is not on a specific date, signals an error if optional
parameter ERROR is non-nil, otherwise just returns nil.
If EVENT is non-nil, it's an event indicating the buffer position to
use instead of point."
(with-current-buffer
(if event (window-buffer (posn-window (event-start event)))
(current-buffer))
(save-excursion
(and event (setq event (event-start event))
(goto-char (posn-point event)))
(let* ((segment (calendar-column-to-segment))
(month (% (+ displayed-month (1- segment)) 12)))
;; Call with point on either of the two digits in a 2-digit date,
;; or on or before the digit of a 1-digit date.
(if (not (and (looking-at "[ 0-9]?[0-9][^0-9]")
(get-text-property (point) 'date)))
(if error (user-error "Not on a date!"))
;; Convert segment to real month and year.
(if (zerop month) (setq month 12))
;; Go back to before the first date digit.
(or (looking-at " ")
(re-search-backward "[^0-9]"))
(list month
(string-to-number
(buffer-substring (1+ (point))
(+ 1 calendar-day-digit-width (point))))
(cond
((and (= 12 month) (zerop segment)) (1- displayed-year))
((and (= 1 month) (= segment 2)) (1+ displayed-year))
(t displayed-year))))))))