created date: add fallback for missing/unexpected title format
This commit is contained in:
parent
72d5616898
commit
7b9266b25d
1 changed files with 4 additions and 2 deletions
|
@ -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')
|
||||
|
|
Loading…
Add table
Reference in a new issue