mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
adds filtering by date with -from and -to
This commit is contained in:
parent
e2559ecf93
commit
c6f324e5d4
1 changed files with 3 additions and 2 deletions
5
jrnl.py
5
jrnl.py
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue