src/pybel/manager/citation_utils.py
def sanitize_date(publication_date: str) -> str:
    """Sanitize lots of different date strings into ISO-8601."""
    if re1.search(publication_date):
        return datetime.strptime(publication_date, '%Y %b %d').strftime('%Y-%m-%d')

    if re2.search(publication_date):
        return datetime.strptime(publication_date, '%Y %b').strftime('%Y-%m-01')

    if re3.search(publication_date):
        return publication_date + "-01-01"

    if re4.search(publication_date):
        return datetime.strptime(publication_date[:-4], '%Y %b').strftime('%Y-%m-01')

    s = re5.search(publication_date)

    if s:
        year, season = s.groups()
        return '{}-{}-01'.format(year, season_map[season])

    s = re6.search(publication_date)

    if s:
        return datetime.strptime(publication_date, '%Y %b %d-{}'.format(s.groups()[0])).strftime('%Y-%m-%d')

    s = re7.search(publication_date)

    if s:
        return datetime.strptime(publication_date, '%Y %b %d-{}'.format(s.groups()[0])).strftime('%Y-%m-%d')
Sanitize lots of different date strings into ISO-8601.
Sanitize lots of different date strings into ISO-8601.
Sanitize lots of different date strings into ISO - 8601 .
def sanitize_date(publication_date: str) -> str:
    if re1.search(publication_date):
        return datetime.strptime(publication_date, '%Y %b %d').strftime('%Y-%m-%d')
    if re2.search(publication_date):
        return datetime.strptime(publication_date, '%Y %b').strftime('%Y-%m-01')
    if re3.search(publication_date):
        return publication_date + "-01-01"
    if re4.search(publication_date):
        return datetime.strptime(publication_date[:-4], '%Y %b').strftime('%Y-%m-01')
    s = re5.search(publication_date)
    if s:
        year, season = s.groups()
        return '{}-{}-01'.format(year, season_map[season])
    s = re6.search(publication_date)
    if s:
        return datetime.strptime(publication_date, '%Y %b %d-{}'.format(s.groups()[0])).strftime('%Y-%m-%d')
    s = re7.search(publication_date)
    if s:
        return datetime.strptime(publication_date, '%Y %b %d-{}'.format(s.groups()[0])).strftime('%Y-%m-%d')
def sanitize_date ( publication_date : str ) -> str : if re1 . search ( publication_date ) : return datetime . strptime ( publication_date , '%Y %b %d' ) . strftime ( '%Y-%m-%d' ) if re2 . search ( publication_date ) : return datetime . strptime ( publication_date , '%Y %b' ) . strftime ( '%Y-%m-01' ) if re3 . search ( publication_date ) : return publication_date + "-01-01" if re4 . search ( publication_date ) : return datetime . strptime ( publication_date [ : - 4 ] , '%Y %b' ) . strftime ( '%Y-%m-01' ) s = re5 . search ( publication_date ) if s : year , season = s . groups ( ) return '{}-{}-01' . format ( year , season_map [ season ] ) s = re6 . search ( publication_date ) if s : return datetime . strptime ( publication_date , '%Y %b %d-{}' . format ( s . groups ( ) [ 0 ] ) ) . strftime ( '%Y-%m-%d' ) s = re7 . search ( publication_date ) if s : return datetime . strptime ( publication_date , '%Y %b %d-{}' . format ( s . groups ( ) [ 0 ] ) ) . strftime ( '%Y-%m-%d' )
Sanitize lots of different date strings into ISO-8601.
Sanitize lots of different date strings into ISO - 8601 .
"""Sanitize lots of different date strings into ISO-8601."""
publication_date
str