def convert(value, row):
    key = key_as_str(value)
    if not key:
        row['arryr'], row['arrmo'], row['arrda'] = 9999, 99, 99
        return value

    try:
        v = key.replace('-', '')
        assert(len(v) == 8)
        assert(1850 <= int(value[:4]) <= date.today().year)
        dt = strptime(v, '%Y%m%d')
        row['arryr'], row['arrmo'], row['arrda'] = dt[0], dt[1], dt[2]
    
    except (AssertionError, ValueError):
        row['arryr'], row['arrmo'], row['arrda'] = 9999, 99, 99
        log.write('arrdatex', [row['id'], row['rapstatex'], value, "invalid date"])
        
    return value
