Function: diary-icalendar-date-form-to-regexp

diary-icalendar-date-form-to-regexp is a byte-compiled function defined in diary-icalendar.el.gz.

Signature

(diary-icalendar-date-form-to-regexp DATE-SEXP)

Documentation

Convert DATE-SEXP to a regular expression.

DATE-SEXP should be an S-expression in the variables year, month, day, monthname, and dayname, as found e.g. in diary-date-forms. The returned regular expression matches dates of this form, including generic dates specified with "*", and abbreviated and long-form month and day names (based on calendar-month-name-array and calendar-month-abbrev-array, and similarly for day names). The match groups contain the following data:

Group 1: the 2-4 digit year, or a literal * Group 2: the 1-2 digit month number, or a literal * Group 3: the 1-2 digit day number, or a literal * Group 4: the (long-form or abbreviated) month name, or a literal * Group 5: the (long-form or abbreviated) day name, or a literal *

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/diary-icalendar.el.gz
(defun di:date-form-to-regexp (date-sexp)
  "Convert DATE-SEXP to a regular expression.

DATE-SEXP should be an S-expression in the variables `year', `month',
`day', `monthname', and `dayname', as found e.g. in `diary-date-forms'.
The returned regular expression matches dates of this form, including
generic dates specified with \"*\", and abbreviated and long-form month
and day names (based on `calendar-month-name-array' and
`calendar-month-abbrev-array', and similarly for day names).  The match
groups contain the following data:

Group 1: the 2-4 digit year, or a literal *
Group 2: the 1-2 digit month number, or a literal *
Group 3: the 1-2 digit day number, or a literal *
Group 4: the (long-form or abbreviated) month name, or a literal *
Group 5: the (long-form or abbreviated) day name, or a literal *"
  (when (eq 'backup (car date-sexp))
    (setq date-sexp (cdr date-sexp)))
  (let ((month-names-regexp
         (rx
          (group-n 4
            (or (regexp (diary-name-pattern calendar-month-name-array
                                            calendar-month-abbrev-array))
                "*"))))
        (day-names-regexp
         (rx
          (group-n 5
            (or (regexp (diary-name-pattern calendar-day-name-array
                                            calendar-day-abbrev-array))
                "*"))))
          date-regexp)
    (calendar-dlet
        ((prefix (rx line-start
                     (zero-or-one (regexp diary-nonmarking-symbol))))
         (year (rx (group-n 1 (or (** 2 4 digit) "*"))))
         (month (rx (group-n 2 (or (** 1 2 digit) "*"))))
         (day (rx (group-n 3 (or (** 1 2 digit) "*"))))
         (monthname month-names-regexp)
         (dayname day-names-regexp))
      (setq date-regexp (apply #'concat (cons prefix (mapcar #'eval date-sexp)))))
  date-regexp))