From 851f8ef0c6cc288790b60f54523a6beb865e50a6 Mon Sep 17 00:00:00 2001 From: Lenahan Michael Date: Thu, 10 Sep 2020 21:01:34 +0200 Subject: [PATCH] Use strict date matching, if using the default time format --- jrnl/Journal.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jrnl/Journal.py b/jrnl/Journal.py index a6bf35d0..8e4853ff 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -128,6 +128,11 @@ class Journal: entries = [] date_blob_re = re.compile("(?:^|\n)\\[([^\\]]+)\\] ") + + # Use strict date matching, if using the default time format + if self.config["timeformat"] == '%Y-%m-%d %H:%M': + date_blob_re = re.compile("(?:^|\n)\\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2})\\] ") + last_entry_pos = 0 for match in date_blob_re.finditer(journal_txt): date_blob = match.groups()[0]