def convert(value, row):
    if not value:
        row['deadyr'], row['deadmo'], row['deadda'] = 9999, 99, 99
        return value
    
    if row['YNDEADX'] != 1:
        row['deadyr'], row['deadmo'], row['deadda'] = 9998, 98, 98

    from datetime import date
    from time import strptime
    
    try:
        v = value.replace('-', '')
        assert(len(v) == 8)
        assert(2000 <= int(value[:4]) <= date.today().year)
        dt = strptime(v, '%Y%m%d')
        row['deadyr'], row['deadmo'], row['deadda'] = dt[0], dt[1], dt[2]
    except AssertionError:
        row['deadyr'], row['deadmo'], row['deadda'] = 9999, 99, 9
        if value != '0000-00-00':
            log.write('dodx', [row['id'], row['rapstatex'], value, "invalid date on key_1"])
        
    return value