Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
fix: manage script fails to recognise date from md (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
sralloza authored Oct 24, 2021
1 parent c18ef79 commit d2c8e5e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions scripts/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ def convert_md_to_yml(date: str):
matches = re.finditer(PATTERN, joined)

current_year = datetime.datetime.now().year
try:
first_date = parse(date).date()
week_number = first_date.isocalendar()[1]
except ValueError:
week_number = int(date)
week_number = int(date)

objs = []
for match in matches:
Expand All @@ -58,11 +54,13 @@ def convert_md_to_yml(date: str):
meal_date = datetime.datetime.strptime(
f"{weekday} {week_number} {current_year}", "%A %W %Y"
).date()

lunch = [x.strip("- ") for x in parsed["lunch"].splitlines()]
if len(lunch) == 2:
lunch1, lunch2 = lunch
else:
lunch1, lunch2 = lunch[0], None

dinner = parsed["dinner"].strip("- ")
obj = dict(date=meal_date, lunch1=lunch1, lunch2=lunch2, dinner=dinner)
objs.append(obj)
Expand Down

0 comments on commit d2c8e5e

Please sign in to comment.