Use strptime in str2datetime

Refactored `str2datetime` to use `datetime.datetime.strptime`. This gives input validation and makes the code more standard.