News for hackers. Stuff that matters.
Re:Code that breaks 2 or 3 times every month by dalke on Friday October 31, 2014 @06:22AM (#8538068)
According to the documentation there's a 'default' parameter, which contains the datetime used to get otherwise unspecified fields. If not given, the default is the current date. Thus to get what you want:

    >>> from datetime import datetime
    >>> from dateutil import parser
    >>> now = datetime.now()
    >>> first = datetime(now.year, now.month, 1, 12, 0, 0)
    >>> dateutil.parser.parse('February 2006', default=first)
    datetime.datetime(2006, 2, 1, 12, 0)

There are no comments on this comment yet.