Compare date start/end.

This commit is contained in:
Tom Alexander
2023-10-02 15:59:06 -04:00
parent c55fae86f8
commit a8a34e2d9c
5 changed files with 115 additions and 46 deletions

View File

@@ -133,8 +133,8 @@ fn active_timestamp<'b, 'g, 'r, 's>(
source: source.into(),
timestamp_type: TimestampType::Active,
range_type: TimestampRangeType::None,
start: Some(start),
end: None,
start: Some(start.clone()),
end: Some(start),
},
))
}
@@ -171,8 +171,8 @@ fn inactive_timestamp<'b, 'g, 'r, 's>(
source: source.into(),
timestamp_type: TimestampType::Inactive,
range_type: TimestampRangeType::None,
start: Some(start),
end: None,
start: Some(start.clone()),
end: Some(start),
},
))
}
@@ -182,10 +182,10 @@ fn active_date_range_timestamp<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Timestamp<'s>> {
let (remaining, _first_timestamp) = active_timestamp(context, input)?;
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, second_timestamp) = active_timestamp(context, remaining)?;
let (remaining, _trailing_whitespace) =
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
@@ -197,8 +197,8 @@ fn active_date_range_timestamp<'b, 'g, 'r, 's>(
source: source.into(),
timestamp_type: TimestampType::ActiveRange,
range_type: TimestampRangeType::DateRange,
start: None, // TODO
end: None, // TODO
start: first_timestamp.start,
end: second_timestamp.end,
},
))
}
@@ -209,7 +209,7 @@ fn active_time_range_timestamp<'b, 'g, 'r, 's>(
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Timestamp<'s>> {
let (remaining, _) = tag("<")(input)?;
let (remaining, _date) = date(context, remaining)?;
let (remaining, start_date) = date(context, remaining)?;
let time_context = ContextElement::ExitMatcherNode(ExitMatcherNode {
class: ExitClass::Gamma,
exit_matcher: &active_time_rest_end,
@@ -242,8 +242,8 @@ fn active_time_range_timestamp<'b, 'g, 'r, 's>(
source: source.into(),
timestamp_type: TimestampType::Active,
range_type: TimestampRangeType::None,
start: None, // TODO
end: None, // TODO
start: Some(start_date.clone()),
end: Some(start_date),
},
))
}
@@ -253,10 +253,10 @@ fn inactive_date_range_timestamp<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Timestamp<'s>> {
let (remaining, _first_timestamp) = inactive_timestamp(context, input)?;
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, second_timestamp) = inactive_timestamp(context, remaining)?;
let (remaining, _trailing_whitespace) =
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
@@ -269,8 +269,8 @@ fn inactive_date_range_timestamp<'b, 'g, 'r, 's>(
timestamp_type: TimestampType::InactiveRange,
range_type: TimestampRangeType::DateRange,
start: None, // TODO
end: None, // TODO
start: first_timestamp.start,
end: second_timestamp.end,
},
))
}
@@ -281,7 +281,7 @@ fn inactive_time_range_timestamp<'b, 'g, 'r, 's>(
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Timestamp<'s>> {
let (remaining, _) = tag("[")(input)?;
let (remaining, _date) = date(context, remaining)?;
let (remaining, start_date) = date(context, remaining)?;
let time_context = ContextElement::ExitMatcherNode(ExitMatcherNode {
class: ExitClass::Gamma,
exit_matcher: &inactive_time_rest_end,
@@ -314,8 +314,8 @@ fn inactive_time_range_timestamp<'b, 'g, 'r, 's>(
source: source.into(),
timestamp_type: TimestampType::Inactive,
range_type: TimestampRangeType::None,
start: None, // TODO
end: None, // TODO
start: Some(start_date.clone()),
end: Some(start_date),
},
))
}