Internal function that tries whatever to convert ``t`` into a
    :class:`datetime.datetime` object.


    >>> _to_datetime('2013-12-11')
    datetime.datetime(2013, 12, 11, 0, 0)
    >>> _to_datetime('Wed, 11 Dec 2013')
    datetime.datetime(2013, 12, 11, 0, 0)
    >>> _to_datetime('Wed, 11 Dec 13')
    datetime.datetime(2013, 12, 11, 0, 0)
    >>> _to_datetime('2012-06-13T15:24:17')
    datetime.datetime(2012, 6, 13, 15, 24, 17)

def _to_datetime(t):
    '''
    Internal function that tries whatever to convert ``t`` into a
    :class:`datetime.datetime` object.


    >>> _to_datetime('2013-12-11')
    datetime.datetime(2013, 12, 11, 0, 0)
    >>> _to_datetime('Wed, 11 Dec 2013')
    datetime.datetime(2013, 12, 11, 0, 0)
    >>> _to_datetime('Wed, 11 Dec 13')
    datetime.datetime(2013, 12, 11, 0, 0)
    >>> _to_datetime('2012-06-13T15:24:17')
    datetime.datetime(2012, 6, 13, 15, 24, 17)

    '''

    if isinstance(t, six.integer_types + (float, )):
        return datetime.datetime.fromtimestamp(t).replace(microsecond=0)

    elif isinstance(t, six.string_types):
        for date_format in ALL_DATETIME_FORMATS:
            try:
                d = datetime.datetime.strptime(t, date_format)
                return d.replace(microsecond=0)
            except ValueError:
                pass

        raise ValueError(_('Format "%s" not supported') % t)

    elif isinstance(t, datetime.datetime):
        return t.replace(microsecond=0)

    elif isinstance(t, datetime.date):
        d = datetime.datetime.combine(t, datetime.time(0, 0))
        return d.replace(microsecond=0)

    else:
        raise TypeError