[Dayone] allow variable length dates on edited Dayone entries

This commit is contained in:
MinchinWeb 2015-05-05 13:21:46 -06:00
parent a329fe4874
commit eed1bd3cb3

View file

@ -4,6 +4,7 @@
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, unicode_literals
from . import Entry from . import Entry
from . import Journal from . import Journal
from . import time as jrnl_time
from . import __title__ # 'jrnl' from . import __title__ # 'jrnl'
from . import __version__ from . import __version__
import os import os
@ -163,8 +164,14 @@ class DayOne(Journal.Journal):
current_entry.uuid = m.group(1).lower() current_entry.uuid = m.group(1).lower()
else: else:
try: try:
# assumes the date is in square brackets date_blob_re = re.compile("^\[[^\\]]+\] ")
new_date = datetime.strptime(line[1:date_length + 1], self.config['timeformat']) 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("*"): if line.endswith("*"):
current_entry.starred = True current_entry.starred = True
line = line[:-1] line = line[:-1]