From c6f324e5d400b05cfb79378e7a741b74cee6e4ce Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Thu, 5 Apr 2012 12:19:07 +0200 Subject: [PATCH] adds filtering by date with -from and -to --- jrnl.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jrnl.py b/jrnl.py index 736be3f5..cb85f88b 100755 --- a/jrnl.py +++ b/jrnl.py @@ -128,14 +128,15 @@ class Journal: If strict is True, all tags must be present in an entry. If false, the entry is kept if any tag is present.""" search_tags = set(tags) + end_date = self.parse_date(end_date) + start_date = self.parse_date(start_date) # If strict mode is on, all tags have to be present in entry tagged = search_tags.issubset if strict else search_tags.intersection - result = [ entry for entry in self.entries if (not tags or tagged(entry.tags)) and (not start_date or entry.date > start_date) - and (not end_date or entry.date < start_date) + and (not end_date or entry.date < end_date) ] self.entries = result