From eed1bd3cb31e7e69d39bdbc3694901cf900704b3 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Tue, 5 May 2015 13:21:46 -0600 Subject: [PATCH] [Dayone] allow variable length dates on edited Dayone entries --- jrnl/DayOneJournal.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jrnl/DayOneJournal.py b/jrnl/DayOneJournal.py index c099e5ab..ca7a5c6d 100644 --- a/jrnl/DayOneJournal.py +++ b/jrnl/DayOneJournal.py @@ -4,6 +4,7 @@ from __future__ import absolute_import, unicode_literals from . import Entry from . import Journal +from . import time as jrnl_time from . import __title__ # 'jrnl' from . import __version__ import os @@ -163,8 +164,14 @@ class DayOne(Journal.Journal): current_entry.uuid = m.group(1).lower() else: try: - # assumes the date is in square brackets - new_date = datetime.strptime(line[1:date_length + 1], self.config['timeformat']) + date_blob_re = re.compile("^\[[^\\]]+\] ") + date_blob = date_blob_re.findall(line) + if date_blob: + date_blob = date_blob[0] + new_date = jrnl_time.parse(date_blob.strip(" []")) + if new_date: + # Found a date at the start of the line: This is a new entry. + pass if line.endswith("*"): current_entry.starred = True line = line[:-1]