(value)
Append midnight to a date

    >>> to_datetime_str('2017-06-27')
    '2017-06-27T00:00:00.000'
Append midnight to a date
Append midnight to a date
def to_datetime_str(value):
    """
    Append midnight to a date

    >>> to_datetime_str('2017-06-27')
    '2017-06-27T00:00:00.000'

    """
    if isinstance(value, str):
        if not re.match(r'\d{4}-\d{2}-\d{2}', value):
            raise ValueError('"{}" is not recognised as a date or a datetime'.format(value))
        value = dateutil_parser.parse(value)
    if isinstance(value, datetime.date):
        value = datetime.datetime(value.year, value.month, value.day)
    if isinstance(value, datetime.datetime):
        return value.isoformat(timespec='milliseconds')
def to_datetime_str ( value ) : if isinstance ( value , str ) : if not re . match ( r'\d{4}-\d{2}-\d{2}' , value ) : raise ValueError ( '"{}" is not recognised as a date or a datetime' . format ( value ) ) value = dateutil_parser . parse ( value ) if isinstance ( value , datetime . date ) : value = datetime . datetime ( value . year , value . month , value . day ) if isinstance ( value , datetime . datetime ) : return value . isoformat ( timespec = 'milliseconds' )