From 374c4f1b8e700e9532fef297837a52be8ad6e4f3 Mon Sep 17 00:00:00 2001 From: NAme <7277505+SocksPls@users.noreply.github.com> Date: Mon, 5 Dec 2022 03:21:39 +0000 Subject: [PATCH] Update month to name function Update month to name function to use the existing datetime import --- main.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/main.py b/main.py index 78b2e99..81d3d11 100644 --- a/main.py +++ b/main.py @@ -34,22 +34,12 @@ def _padIfNeeded(numberStr: str): return str(numberStr) def _monthNameToNumber(monthName: str): - months = { - 'January': 1, - 'February': 2, - 'March': 3, - 'April': 4, - 'May': 5, - 'June': 6, - 'July': 7, - 'August': 8, - 'Augu': 8, - 'September': 9, - 'October': 10, - 'November': 11, - 'December': 12 - } - return months[monthName] + # Check for the input "Augu" and convert it to "August" + # This is necessary because the input string may have been sanitized + # by removing the "st" from the day numbers, such as "21st" -> "21" + if monthName == "Augu": + monthName = "August" + return datetime.strptime(monthName, '%B').month def get_parsed_page(url, delay=0.5): # This fixes a blocked by cloudflare error i've encountered