mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 21:18:32 +02:00
Introduce timeformat_strict configuration
This commit is contained in:
parent
82f3bf732a
commit
455db728c0
1 changed files with 6 additions and 2 deletions
|
@ -31,6 +31,7 @@ class Journal:
|
||||||
"default_hour": 9,
|
"default_hour": 9,
|
||||||
"default_minute": 0,
|
"default_minute": 0,
|
||||||
"timeformat": "%Y-%m-%d %H:%M",
|
"timeformat": "%Y-%m-%d %H:%M",
|
||||||
|
"timeformat_strict": False,
|
||||||
"tagsymbols": "@",
|
"tagsymbols": "@",
|
||||||
"highlight": True,
|
"highlight": True,
|
||||||
"linewrap": 80,
|
"linewrap": 80,
|
||||||
|
@ -129,9 +130,12 @@ class Journal:
|
||||||
|
|
||||||
date_blob_re = re.compile("(?:^|\n)\\[([^\\]]+)\\] ")
|
date_blob_re = re.compile("(?:^|\n)\\[([^\\]]+)\\] ")
|
||||||
|
|
||||||
# Use strict date matching, if using the default time format
|
# Use strict date matching
|
||||||
|
# (1) if using the default time format, and
|
||||||
|
# (2) if timeformat_strict is set to true.
|
||||||
if self.config["timeformat"] == "%Y-%m-%d %H:%M":
|
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})\\] ")
|
if self.config["timeformat_strict"]:
|
||||||
|
date_blob_re = re.compile("(?:^|\n)\\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2})\\] ")
|
||||||
|
|
||||||
last_entry_pos = 0
|
last_entry_pos = 0
|
||||||
for match in date_blob_re.finditer(journal_txt):
|
for match in date_blob_re.finditer(journal_txt):
|
||||||
|
|
Loading…
Add table
Reference in a new issue