Skip to content

Commit

Permalink
Updated worker
Browse files Browse the repository at this point in the history
  • Loading branch information
rastislavcore committed Feb 27, 2024
1 parent d1ea757 commit 735e74e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions update_frontmatter.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import frontmatter
import os
from datetime import datetime, timedelta
from datetime import datetime, date

def parse_date(date_str):
formats = ['%Y-%m-%d', '%Y-%m-%dT%H:%M:%S.%fZ', '%Y-%m-%dT%H:%M:%SZ']
if isinstance(date_str, datetime):
return date_str
elif isinstance(date_str, date):
return datetime(date_str.year, date_str.month, date_str.day)

formats = ['%Y-%m-%d', '%Y-%m-%dT%H:%M:%S.%fZ', '%Y-%m-%dT%H:%M:%SZ', '%Y-%m-%dT%H:%M', '%Y-%m-%d %H:%M']
for fmt in formats:
try:
return datetime.strptime(date_str, fmt)
Expand Down

0 comments on commit 735e74e

Please sign in to comment.