(dtstr, validate=False)
return dtstr
Pad datetime to make a 14-digit string and optionally validate it
Pad datetime to make a 14-digit string and optionally validate it
Pad datetime to make a 14 - digit string and optionally validate it
def pad_digits14(dtstr, validate=False):
    '''Pad datetime to make a 14-digit string and optionally validate it'''
    match = dt_pattern.match(dtstr)
    if match:
        Y = match.group(1)
        m = match.group(2) or '01'
        d = match.group(3) or '01'
        H = match.group(4) or '00'
        M = match.group(5) or '00'
        S = match.group(6) or '00'
        dtstr = f'{Y}{m}{d}{H}{M}{S}'
    if validate:
        datetime.datetime.strptime(dtstr, '%Y%m%d%H%M%S')
    return dtstr
def pad_digits14 ( dtstr , validate = False ) : match = dt_pattern . match ( dtstr ) if match : Y = match . group ( 1 ) m = match . group ( 2 ) or '01' d = match . group ( 3 ) or '01' H = match . group ( 4 ) or '00' M = match . group ( 5 ) or '00' S = match . group ( 6 ) or '00' dtstr = f'{Y}{m}{d}{H}{M}{S}' if validate : datetime . datetime . strptime ( dtstr , '%Y%m%d%H%M%S' ) return dtstr