pub fn mask_date_format(
    field_in_struct: &mut fetchjsonformatmod::CtrlFormat,
    ctrl_value: &str,
) -> String {
    let mut ret_val = ctrl_value.to_string();
    logmod::debug_write(&format!("ctrl_value: {}", &ctrl_value));
    //make a local old_value
    let old_value = field_in_struct.value.clone();
    logmod::debug_write(&format!("old_value: {}", &old_value));

    //get rid of all non numeric characters
    let mut v = String::with_capacity(10);
    for x in ctrl_value.chars() {
        if char::is_numeric(x) {
            v.push(x);
        }
    }
    logmod::debug_write(&format!("v: {}", &v));
    if v.len() > 8 {
        v = v[0..8].to_string();
    }
    logmod::debug_write(&format!("v: {}", &v));
    logmod::debug_write(&format!("old_value len: {}", old_value.len()));
    logmod::debug_write(&format!("ctrl_value len: {}", ctrl_value.len()));
    if old_value.len() <= ctrl_value.len() {
        if v.len() > 4 {
            ret_val = stringmod::concat_5(&v[0..2], "/", &v[2..4], "/", &v[4..]);
        } else if v.len() == 4 {
            ret_val = stringmod::concat_5(&v[0..2], "/", &v[2..4], "/", "");
        } else if v.len() > 2 {
            ret_val = stringmod::concat_5(&v[0..2], "/", &v[2..], "", "");
        } else if v.len() == 2 {
            ret_val = stringmod::concat_5(&v[0..2], "/", "", "", "");
        } else if v.is_empty() {
            ret_val = "dd/mm/yyyy".to_string();
        } else {
            ret_val = v;
        }
    }
    //return
    ret_val
}
// I always check the len() of the string first
I always check the len() of the string first
I always check the len () of the string first
pub fn mask_date_format(
    field_in_struct: &mut fetchjsonformatmod::CtrlFormat,
    ctrl_value: &str,
) -> String {
    let mut ret_val = ctrl_value.to_string();
    logmod::debug_write(&format!("ctrl_value: {}", &ctrl_value));
    //make a local old_value
    let old_value = field_in_struct.value.clone();
    logmod::debug_write(&format!("old_value: {}", &old_value));
    //get rid of all non numeric characters
    let mut v = String::with_capacity(10);
    for x in ctrl_value.chars() {
        if char::is_numeric(x) {
            v.push(x);
        }
    }
    logmod::debug_write(&format!("v: {}", &v));
    if v.len() > 8 {
        v = v[0..8].to_string();
    }
    logmod::debug_write(&format!("v: {}", &v));
    logmod::debug_write(&format!("old_value len: {}", old_value.len()));
    logmod::debug_write(&format!("ctrl_value len: {}", ctrl_value.len()));
    if old_value.len() <= ctrl_value.len() {
        if v.len() > 4 {
            ret_val = stringmod::concat_5(&v[0..2], "/", &v[2..4], "/", &v[4..]);
        } else if v.len() == 4 {
            ret_val = stringmod::concat_5(&v[0..2], "/", &v[2..4], "/", "");
        } else if v.len() > 2 {
            ret_val = stringmod::concat_5(&v[0..2], "/", &v[2..], "", "");
        } else if v.len() == 2 {
            ret_val = stringmod::concat_5(&v[0..2], "/", "", "", "");
        } else if v.is_empty() {
            ret_val = "dd/mm/yyyy".to_string();
        } else {
            ret_val = v;
        }
    }
    //return
    ret_val
}
pub fn mask_date_format ( field_in_struct : & mut fetchjsonformatmod :: CtrlFormat , ctrl_value : & str , ) -> String { let mut ret_val = ctrl_value . to_string ( ) ; logmod :: debug_write ( & format ! ( " " ctrl_value ) ) ; //make a local old_value let old_value = field_in_struct . value . clone ( ) ; logmod :: debug_write ( & format ! ( " " old_value ) ) ; //get rid of all non numeric characters let mut v = String :: with_capacity ( 10 ) ; for x in ctrl_value . chars ( ) { if char :: is_numeric ( x ) { v . push ( x ) ; } } logmod :: debug_write ( & format ! ( " " v ) ) ; if v . len ( ) > 8 { v = v [ 0 .. 8 ] . to_string ( ) ; } logmod :: debug_write ( & format ! ( " " v ) ) ; logmod :: debug_write ( & format ! ( " " old_value len ( ) ) ) ; logmod :: debug_write ( & format ! ( " " ctrl_value len ( ) ) ) ; if old_value . len ( ) <= ctrl_value . len ( ) { if v . len ( ) > 4 { ret_val = stringmod :: concat_5 ( & v [ 0 .. 2 ] , " " , & v [ 2 .. 4 ] , " " , & v [ 4 .. ] ) ; } else if v . len ( ) == 4 { ret_val = stringmod :: concat_5 ( & v [ 0 .. 2 ] , " " , & v [ 2 .. 4 ] , " " , " " ) ; } else if v . len ( ) > 2 { ret_val = stringmod :: concat_5 ( & v [ 0 .. 2 ] , " " , & v [ 2 .. ] , " " , " " ) ; } else if v . len ( ) == 2 { ret_val = stringmod :: concat_5 ( & v [ 0 .. 2 ] , " " , " " , " " , " " ) ; } else if v . is_empty ( ) { ret_val = " " . to_string ( ) ; } else { ret_val = v ; } } //return ret_val }
I always check the len() of the string first
I always check the len () of the string first
field_in_struct
&mut fetchjsonformatmod::CtrlFormat
ctrl_value
&str
field_in_struct
&mut fetchjsonformatmod::CtrlFormat
ctrl_value
&str