Fix a bug in the "add book" script – date_read is always a datetime
authorAlex Chan <alex@alexwlchan.net>
Fri, 7 Feb 2020 19:29:33 +0000 (19:29 +0000)
committerAlex Chan <alex@alexwlchan.net>
Fri, 7 Feb 2020 19:29:33 +0000 (19:29 +0000)
Previously you'd get a mixture of str() and datetime.date(), depending
on whether you selected "today/yesterday" or "another day".  The calling
code assumed a datetime.date(), so ensure this is correct.

scripts/add_book.py

index ad3cde9..74ebf9b 100755 (executable)
@@ -68,10 +68,10 @@ def get_review_info():
     today = datetime.datetime.now()
 
     if date_read == "today":
-        date_read = today.strftime("%Y-%m-%d")
+        date_read = today.date()
     elif date_read == "yesterday":
         yesterday = today - datetime.timedelta(days=1)
-        date_read = yesterday.strftime("%Y-%m-%d")
+        date_read = yesterday.date()
     else:
         date_read_question2 = [
             inquirer.Text("date_read", message="When did you finish reading it?")