changed date

This commit is contained in:
Marc Mance
2024-05-29 18:31:15 -04:00
parent c516367473
commit a8f4d6602b

View File

@@ -6,7 +6,6 @@ from datetime import datetime
def convert_to_machine_readable(date_string): def convert_to_machine_readable(date_string):
print(f"converting {date_string}")
# Define the format string considering the time zone information (EDT) # Define the format string considering the time zone information (EDT)
format_string = "%a %b %d %H:%M:%S %p %Z %Y" format_string = "%a %b %d %H:%M:%S %p %Z %Y"
try: try:
@@ -14,9 +13,11 @@ def convert_to_machine_readable(date_string):
datetime_obj = datetime.strptime(date_string, format_string) datetime_obj = datetime.strptime(date_string, format_string)
return datetime_obj return datetime_obj
except ValueError: except ValueError:
print(f"given: {date_string}")
print( print(
f"Error: Invalid date format. Please provide a string in the format '{format_string}'." f"Error: Invalid date format. Please provide a string in the format '{format_string}'."
) )
return None return None