created date: add fallback for missing/unexpected title format

This commit is contained in:
Dima Gerasimov 2020-04-17 21:39:28 +01:00
parent 72d5616898
commit 7b9266b25d

View file

@ -42,10 +42,12 @@ class Node(NamedTuple):
# ugh. daily notes don't have create time for some reason???
title = self.title
assert title is not None
if title is None:
return self.edited # fallback TODO log?
# the format is 'February 8th, 2020'. Fucking hell.
m = re.fullmatch(r'(\w+) (\d+)\w+, (\d+)', title)
assert m is not None
if m is None:
return self.edited # fallback TODO log?
# strip off 'th'/'rd' crap
dts = m.group(1) + ' ' + m.group(2) + ' ' + m.group(3)
dt = datetime.strptime(dts, '%B %d %Y')