dateutil parser without defaults

71 Views Asked by At

It is driving me crazy. I really dislike the library, but sadly I've not been able to find anything better.

What's particularly bothering me is that it is giving defaults. It gives the option to change the defaults, but only to a datetime object.

I'd like to get year and month with certainty, but at this stage there is no way to know for sure whether the month is "real" or whether it has taken the default value.

Simple example:

>>> dateutil.parser.parse('')
datetime.datetime(2015, 06, 08, 0, 0, 0) # note that it takes defaults for Y/M/D

Of course, the empty string is just a simple example and could be tested differently.

The only way I can think of is to parse everything twice with different defaults, and then only objects that remain equal must be good.

Did anyone find a way to deal with this issue?

0

There are 0 best solutions below