Skip to content

Commit

Permalink
#532 Improve date format validation to include all supported cases | …
Browse files Browse the repository at this point in the history
…fmt applied
  • Loading branch information
Arkadiusz Bielewicz authored and meain committed Oct 14, 2021
1 parent 19fb1c6 commit b3a1dee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
12 changes: 10 additions & 2 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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),
);
}

0 comments on commit b3a1dee

Please sign in to comment.