From 1a5b7ca30c82b7cf004b76a057a5f96cb352e65f Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 27 Jul 2023 19:59:36 -0400 Subject: [PATCH] Implement parser for active/inactive timestamp date ranges. --- src/parser/timestamp.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/parser/timestamp.rs b/src/parser/timestamp.rs index b56b267..fc21198 100644 --- a/src/parser/timestamp.rs +++ b/src/parser/timestamp.rs @@ -136,8 +136,15 @@ fn active_date_range_timestamp<'r, 's>( context: Context<'r, 's>, input: &'s str, ) -> Res<&'s str, Timestamp<'s>> { - not_yet_implemented()?; - todo!() + let (remaining, _first_timestamp) = active_timestamp(context, input)?; + // TODO: Does the space0 at the end of the active/inactive timestamp parsers cause this to be incorrect? I could use a look-behind to make sure the preceding character is not whitespace + let (remaining, _separator) = tag("--")(remaining)?; + let (remaining, _second_timestamp) = active_timestamp(context, remaining)?; + + let (remaining, _) = space0(remaining)?; + let source = get_consumed(input, remaining); + + Ok((remaining, Timestamp { source })) } #[tracing::instrument(ret, level = "debug")] @@ -154,8 +161,15 @@ fn inactive_date_range_timestamp<'r, 's>( context: Context<'r, 's>, input: &'s str, ) -> Res<&'s str, Timestamp<'s>> { - not_yet_implemented()?; - todo!() + let (remaining, _first_timestamp) = inactive_timestamp(context, input)?; + // TODO: Does the space0 at the end of the active/inactive timestamp parsers cause this to be incorrect? I could use a look-behind to make sure the preceding character is not whitespace + let (remaining, _separator) = tag("--")(remaining)?; + let (remaining, _second_timestamp) = inactive_timestamp(context, remaining)?; + + let (remaining, _) = space0(remaining)?; + let source = get_consumed(input, remaining); + + Ok((remaining, Timestamp { source })) } #[tracing::instrument(ret, level = "debug")]