Skip to content

Instantly share code, notes, and snippets.

@rschulman
Created November 18, 2017 19:31
Show Gist options
  • Save rschulman/f982e1750ea4aae523d59209f9eca666 to your computer and use it in GitHub Desktop.
Save rschulman/f982e1750ea4aae523d59209f9eca666 to your computer and use it in GitHub Desktop.
named!(date<&str, NaiveDateTime>, do_parse!(
y: digit >>
tag_s!("-") >>
m: digit >>
tag_s!("-") >>
d: digit >>
new_time: value!(NaiveTime::from_hms(0, 0, 0), do_parse(
alt!(tag_s!("T") | tag_s!(" ")) >>
time)) >>
(NaiveDateTime::new(NaiveDate::from_ymd(i32::from_str(y).unwrap(), u32::from_str(m).unwrap(), u32::from_str(d).unwrap()), new_time))
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment