(arg_datetime_str)
custom argparse type for user datetime values given from the command line
custom argparse type for user datetime values given from the command line
custom argparse type for user datetime values given from the command line
def valid_datetime_type(arg_datetime_str):
    '''
    custom argparse type for user datetime values given from the command line
    '''
    if arg_datetime_str is None:
        return None
    try:
        return datetime.strptime(arg_datetime_str, "%Y-%m-%d %H:%M:%S")
    except ValueError:
        msg = "Given Datetime ({0}) not valid! Expected format, 'YYYY-MM-DD HH:mm:ss'! (use ' around the date/time)".format(arg_datetime_str)
        raise argparse.ArgumentTypeError(msg)
def valid_datetime_type ( arg_datetime_str ) : if arg_datetime_str is None : return None try : return datetime . strptime ( arg_datetime_str , "%Y-%m-%d %H:%M:%S" ) except ValueError : msg = "Given Datetime ({0}) not valid! Expected format, 'YYYY-MM-DD HH:mm:ss'! (use ' around the date/time)" . format ( arg_datetime_str ) raise argparse . ArgumentTypeError ( msg )