summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2015-07-22 20:34:44 -0700
committerCraig Earls <enderw88@gmail.com>2015-07-22 20:34:44 -0700
commit254d82e5eb123feaf87e3f7096a1f8389bac60b3 (patch)
tree55f8fe9dc06311031acf6450f5f056f0b8e5d96e /lisp
parentde651d247bf5d578e2604a93c1889eae1c9e4f78 (diff)
downloadfork-ledger-254d82e5eb123feaf87e3f7096a1f8389bac60b3.tar.gz
fork-ledger-254d82e5eb123feaf87e3f7096a1f8389bac60b3.tar.bz2
fork-ledger-254d82e5eb123feaf87e3f7096a1f8389bac60b3.zip
Make advanced day descriptor automatically wildcard year and month.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ledger-schedule.el34
1 files changed, 19 insertions, 15 deletions
diff --git a/lisp/ledger-schedule.el b/lisp/ledger-schedule.el
index b715a487..e60a285d 100644
--- a/lisp/ledger-schedule.el
+++ b/lisp/ledger-schedule.el
@@ -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
date descriptor."
- (cond ((string= year-desc "*") t)
- ((/= 0 (string-to-number year-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))))
+ (cond
+ ((string-match "[A-Za-z]" day-desc) t) ; there is an advanced day descriptor which overrides the year
+ ((string= year-desc "*") t)
+ ((/= 0 (string-to-number year-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)
"Return a form that constrains the month.
YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the
date descriptor."
- (cond ((string= month-desc "*")
- t) ;; always match
- ((string= month-desc "E") ;; Even
- `(evenp (nth 4 (decode-time date))))
- ((string= month-desc "O") ;; Odd
- `(oddp (nth 4 (decode-time date))))
- ((/= 0 (string-to-number month-desc)) ;; Starts with number
- `(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))))
+ (cond
+ ((string-match "[A-Za-z]" day-desc) t) ; there is an advanced day descriptor which overrides the month
+ ((string= month-desc "*")
+ t) ;; always match
+ ((string= month-desc "E") ;; Even
+ `(evenp (nth 4 (decode-time date))))
+ ((string= month-desc "O") ;; Odd
+ `(oddp (nth 4 (decode-time date))))
+ ((/= 0 (string-to-number month-desc)) ;; Starts with number
+ `(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)
"Return a form that constrains the day.