Make advanced day descriptor automatically wildcard year and month.

This commit is contained in:
Craig Earls 2015-07-22 20:34:44 -07:00
parent de651d247b
commit 254d82e5eb

View file

@ -212,27 +212,31 @@ the transaction should be logged for that day."
YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the
date descriptor." date descriptor."
(cond ((string= year-desc "*") t) (cond
((/= 0 (string-to-number year-desc)) ((string-match "[A-Za-z]" day-desc) t) ; there is an advanced day descriptor which overrides the year
`(memq (nth 5 (decode-time date)) ',(mapcar 'string-to-number (split-string year-desc ",")))) ((string= year-desc "*") t)
(t ((/= 0 (string-to-number year-desc))
(error "Improperly specified year constraint: %s %s %s" year-desc month-desc day-desc)))) `(memq (nth 5 (decode-time date)) ',(mapcar 'string-to-number (split-string year-desc ","))))
(t
(error "Improperly specified year constraint: %s %s %s" year-desc month-desc day-desc))))
(defun ledger-schedule-constrain-month (year-desc month-desc day-desc) (defun ledger-schedule-constrain-month (year-desc month-desc day-desc)
"Return a form that constrains the month. "Return a form that constrains the month.
YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the
date descriptor." date descriptor."
(cond ((string= month-desc "*") (cond
t) ;; always match ((string-match "[A-Za-z]" day-desc) t) ; there is an advanced day descriptor which overrides the month
((string= month-desc "E") ;; Even ((string= month-desc "*")
`(evenp (nth 4 (decode-time date)))) t) ;; always match
((string= month-desc "O") ;; Odd ((string= month-desc "E") ;; Even
`(oddp (nth 4 (decode-time date)))) `(evenp (nth 4 (decode-time date))))
((/= 0 (string-to-number month-desc)) ;; Starts with number ((string= month-desc "O") ;; Odd
`(memq (nth 4 (decode-time date)) ',(mapcar 'string-to-number (split-string month-desc ",")))) `(oddp (nth 4 (decode-time date))))
(t ((/= 0 (string-to-number month-desc)) ;; Starts with number
(error "Improperly specified month constraint: %s %s %s" year-desc month-desc day-desc)))) `(memq (nth 4 (decode-time date)) ',(mapcar 'string-to-number (split-string month-desc ","))))
(t
(error "Improperly specified month constraint: %s %s %s" year-desc month-desc day-desc))))
(defun ledger-schedule-constrain-day (year-desc month-desc day-desc) (defun ledger-schedule-constrain-day (year-desc month-desc day-desc)
"Return a form that constrains the day. "Return a form that constrains the day.