summaryrefslogtreecommitdiffstats
path: root/cli/src/search.rs
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-08-03 14:42:47 +0200
committerGustav Sörnäs <gustav@sornas.net>2021-08-03 14:42:47 +0200
commit6496950ebd49bb3ec88c2cb5dd7a62771d57d38e (patch)
treef6fbff07ff307fe841755aeaac14c0f7ae655c52 /cli/src/search.rs
parent7f15f58224b959b7d62206580d797a71e4cbec9c (diff)
downloadmoney-6496950ebd49bb3ec88c2cb5dd7a62771d57d38e.tar.gz
use chrono parsing
Diffstat (limited to 'cli/src/search.rs')
-rw-r--r--cli/src/search.rs17
1 files changed, 3 insertions, 14 deletions
diff --git a/cli/src/search.rs b/cli/src/search.rs
index d4c107b..50ab32a 100644
--- a/cli/src/search.rs
+++ b/cli/src/search.rs
@@ -22,20 +22,9 @@ impl DateIsh {
// }
fn parse(i: &str) -> nom::IResult<&str, Self> {
map(
- map_opt(
- map_res(
- tuple((
- take(4usize),
- char('-'),
- take(2usize),
- char('-'),
- take(2usize),
- )),
- |(y, _, m, _, d): (&str, _, &str, _, &str)| -> Result<_, ParseIntError> {
- Ok((y.parse()?, m.parse()?, d.parse()?))
- }
- ),
- |(y, m, d)| NaiveDate::from_ymd_opt(y, m, d)
+ map_res(
+ take(10usize),
+ |s| NaiveDate::parse_from_str(s, "%Y-%m-%d"),
),
DateIsh::Absolute
)(i)