#532 Improve date format validation to include all supported cases | fmt applied

This commit is contained in:
Arkadiusz Bielewicz 2021-10-13 13:45:55 +02:00 committed by Abin Simon
parent 19fb1c68a5
commit b3a1dee4c6
2 changed files with 11 additions and 3 deletions

View file

@ -318,7 +318,7 @@ pub fn validate_time_format(formatter: &str) -> Result<(), String> {
| Some('W') | Some('w') | Some('Y') | Some('y') => (),
Some(c) => return Err(format!("invalid format specifier: %{}{}", n, c)),
None => return Err("missing format specifier".to_owned()),
}
},
Some('A') | Some('a') | Some('B') | Some('b') | Some('C') | Some('c')
| Some('D') | Some('d') | Some('e') | Some('F') | Some('f') | Some('G')
| Some('g') | Some('H') | Some('h') | Some('I') | Some('j') | Some('k')

View file

@ -606,7 +606,11 @@ fn test_date_custom_format_supports_nanos_with_length() {
.arg("--ignore-config")
.arg(dir.path())
.assert()
.stdout(predicate::str::is_match("testDateFormat\\.[0-9]{3}").unwrap().count(2));
.stdout(
predicate::str::is_match("testDateFormat\\.[0-9]{3}")
.unwrap()
.count(2),
);
}
#[test]
@ -622,5 +626,9 @@ fn test_date_custom_format_supports_padding() {
.arg("--ignore-config")
.arg(dir.path())
.assert()
.stdout(predicate::str::is_match("testDateFormat[\\s0-9]{2}").unwrap().count(2));
.stdout(
predicate::str::is_match("testDateFormat[\\s0-9]{2}")
.unwrap()
.count(2),
);
}