Python 2.7: implementing date parsing using dateutil.parser on non-standard formats
I'm integrating two systems and I'm trying to figure out I'm reviewing some code and I'm not sure how to approach I'm having trouble parsing dates in a non-standard format using the `dateutil.parser` module in Python 2.7... My input dates are in the format 'DD-MM-YYYY HH:MM:SS', but when I try to parse them, I get the following behavior: ``` ValueError: unconverted data remains: 12:00:00 ``` Here's the code I've been using: ```python from dateutil import parser date_str = '25-12-2023 12:00:00' parsed_date = parser.parse(date_str) ``` I expected `parsed_date` to give me a datetime object representing December 25, 2023, at 12:00 PM. However, I see that `dateutil.parser` is not able to interpret the day-first format correctly. I've tried various combinations of formatting and even looked into using `datetime.strptime`, but I'm still running into issues. Here's what I tried with `strptime`: ```python from datetime import datetime date_str = '25-12-2023 12:00:00' parsed_date = datetime.strptime(date_str, '%d-%m-%Y %H:%M:%S') ``` This works fine and gives me the correct output, but I would prefer the flexibility of `dateutil.parser`, especially since my input format might change. Is there a way to configure `dateutil.parser` to accept this format or to ensure it can handle different formats gracefully without throwing an behavior? Any suggestions would be appreciated! I'd love to hear your thoughts on this. How would you solve this? For reference, this is a production microservice. I'd really appreciate any guidance on this. My team is using Python for this mobile app.