adds filtering by date with -from and -to

This commit is contained in:
Manuel Ebert 2012-04-05 12:19:07 +02:00
parent e2559ecf93
commit c6f324e5d4

View file

@ -128,14 +128,15 @@ class Journal:
If strict is True, all tags must be present in an entry. If false, the If strict is True, all tags must be present in an entry. If false, the
entry is kept if any tag is present.""" entry is kept if any tag is present."""
search_tags = set(tags) 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 # If strict mode is on, all tags have to be present in entry
tagged = search_tags.issubset if strict else search_tags.intersection tagged = search_tags.issubset if strict else search_tags.intersection
result = [ result = [
entry for entry in self.entries entry for entry in self.entries
if (not tags or tagged(entry.tags)) if (not tags or tagged(entry.tags))
and (not start_date or entry.date > start_date) 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 self.entries = result