Implement the new fields for timestamp.
This commit is contained in:
parent
68dccd54b1
commit
87ce7d7432
@ -69,7 +69,7 @@ fn diary_timestamp<'b, 'g, 'r, 's>(
|
||||
let (remaining, _) = tag("<%%(")(input)?;
|
||||
let (remaining, _body) = sexp(context, remaining)?;
|
||||
let (remaining, _) = tag(")>")(remaining)?;
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
@ -85,6 +85,7 @@ fn diary_timestamp<'b, 'g, 'r, 's>(
|
||||
end_time: None,
|
||||
repeater: None,
|
||||
warning_delay: None,
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@ -159,7 +160,7 @@ fn active_timestamp<'b, 'g, 'r, 's>(
|
||||
)))(remaining)?;
|
||||
let (remaining, _) = tag(">")(remaining)?;
|
||||
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
@ -175,6 +176,7 @@ fn active_timestamp<'b, 'g, 'r, 's>(
|
||||
end_time: time.map(|(_, time)| time),
|
||||
repeater: repeater.map(|(_, repeater)| repeater),
|
||||
warning_delay: warning_delay.map(|(_, warning_delay)| warning_delay),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@ -213,7 +215,7 @@ pub(crate) fn inactive_timestamp<'b, 'g, 'r, 's>(
|
||||
)))(remaining)?;
|
||||
let (remaining, _) = tag("]")(remaining)?;
|
||||
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
@ -229,6 +231,7 @@ pub(crate) fn inactive_timestamp<'b, 'g, 'r, 's>(
|
||||
end_time: time.map(|(_, time)| time),
|
||||
repeater: repeater.map(|(_, repeater)| repeater),
|
||||
warning_delay: warning_delay.map(|(_, warning_delay)| warning_delay),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@ -246,7 +249,7 @@ fn active_date_range_timestamp<'b, 'g, 'r, 's>(
|
||||
let (remaining, _separator) = tag("--")(remaining)?;
|
||||
let (remaining, second_timestamp) = active_timestamp(context, remaining)?;
|
||||
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
@ -264,6 +267,7 @@ fn active_date_range_timestamp<'b, 'g, 'r, 's>(
|
||||
warning_delay: first_timestamp
|
||||
.warning_delay
|
||||
.or(second_timestamp.warning_delay),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@ -302,7 +306,7 @@ fn active_time_range_timestamp<'b, 'g, 'r, 's>(
|
||||
)))(remaining)?;
|
||||
let (remaining, _) = tag(">")(remaining)?;
|
||||
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
@ -318,6 +322,7 @@ fn active_time_range_timestamp<'b, 'g, 'r, 's>(
|
||||
end_time: Some(second_time),
|
||||
repeater: repeater.map(|(_, repeater)| repeater),
|
||||
warning_delay: warning_delay.map(|(_, warning_delay)| warning_delay),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@ -335,7 +340,7 @@ pub(crate) fn inactive_date_range_timestamp<'b, 'g, 'r, 's>(
|
||||
let (remaining, _separator) = tag("--")(remaining)?;
|
||||
let (remaining, second_timestamp) = inactive_timestamp(context, remaining)?;
|
||||
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
@ -354,6 +359,7 @@ pub(crate) fn inactive_date_range_timestamp<'b, 'g, 'r, 's>(
|
||||
warning_delay: first_timestamp
|
||||
.warning_delay
|
||||
.or(second_timestamp.warning_delay),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@ -392,7 +398,7 @@ pub(crate) fn inactive_time_range_timestamp<'b, 'g, 'r, 's>(
|
||||
)))(remaining)?;
|
||||
let (remaining, _) = tag("]")(remaining)?;
|
||||
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
@ -408,6 +414,7 @@ pub(crate) fn inactive_time_range_timestamp<'b, 'g, 'r, 's>(
|
||||
end_time: Some(second_time),
|
||||
repeater: repeater.map(|(_, repeater)| repeater),
|
||||
warning_delay: warning_delay.map(|(_, warning_delay)| warning_delay),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
@ -299,6 +299,7 @@ pub struct Timestamp<'s> {
|
||||
pub end_time: Option<Time<'s>>,
|
||||
pub repeater: Option<Repeater>,
|
||||
pub warning_delay: Option<WarningDelay>,
|
||||
pub post_blank: Option<&'s str>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@ -964,11 +965,15 @@ impl<'s> StandardProperties<'s> for Timestamp<'s> {
|
||||
}
|
||||
|
||||
fn get_contents<'b>(&'b self) -> Option<&'s str> {
|
||||
todo!()
|
||||
None
|
||||
}
|
||||
|
||||
fn get_post_blank(&self) -> PostBlank {
|
||||
todo!()
|
||||
self.post_blank
|
||||
.map(|text| text.chars().count())
|
||||
.unwrap_or(0)
|
||||
.try_into()
|
||||
.expect("Too much post-blank to fit into a PostBlank.")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user