import re
from datetime import datetime
import time


def extract_date(str_date):
    """Find the first %Y-%m-%d string
       and return the datetime and the remainder of the string
    """
    rgx = re.compile('\d{4}-\d{2}-\d{2}')
    o_match = rgx.search(str_date)
    if o_match is not None:
        i_start = o_match.start()
        i_end = i_start+10
        return (datetime(
            *(time.strptime(str_date[i_start:i_end], "%Y-%m-%d")[0:6])),
            str_date[0:i_start] + str_date[i_end:])
    else:
        return (None, str_date)