Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def main():
return

deadline = format_date(args.deadline)
if deadline == "error":
print(f"Error: '{args.deadline}' is not a valid date. Please use YYYY-MM-DD format and ensure the date actually exists.")
return
assignment = manager.add_assignment(args.value, deadline, args.subject)
print(f"Added assignment: {assignment['title']}")

Expand Down Expand Up @@ -57,4 +60,4 @@ def main():


if __name__ == '__main__':
main()
main()
3 changes: 1 addition & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class TestUtils(unittest.TestCase):

def test_format_date_valid(self):
"""Test format_date with valid date string"""
result = format_date("2024-12-25")
Expand Down Expand Up @@ -44,4 +43,4 @@ def test_get_priority_level(self):


if __name__ == '__main__':
unittest.main()
unittest.main()
8 changes: 6 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
def format_date(date_string):
"""Convert date string to datetime object"""
# TODO: Add error handling for invalid date formats
return datetime.strptime(date_string, "%Y-%m-%d")
try:
myDate = datetime.strptime(date_string, "%Y-%m-%d")
return myDate
except ValueError:
return "error"


def calculate_days_remaining(deadline):
Expand Down Expand Up @@ -50,4 +54,4 @@ def get_priority_level(days_remaining):
elif days_remaining <= 7:
return "MEDIUM"
else:
return "LOW"
return "LOW"