mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-14 14:12:31 +00:00
#532 Improve date format validation to include all supported cases | fmt applied
This commit is contained in:
parent
19fb1c68a5
commit
b3a1dee4c6
2 changed files with 11 additions and 3 deletions
|
@ -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')
|
||||
|
|
|
@ -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),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue