summaryrefslogtreecommitdiffstats
path: root/vendor/time/src/parsing/component.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/time/src/parsing/component.rs')
-rw-r--r--vendor/time/src/parsing/component.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/vendor/time/src/parsing/component.rs b/vendor/time/src/parsing/component.rs
index 23035893e..42d15e9f6 100644
--- a/vendor/time/src/parsing/component.rs
+++ b/vendor/time/src/parsing/component.rs
@@ -316,12 +316,12 @@ pub(crate) fn parse_unix_timestamp(
let ParsedItem(input, sign) = opt(sign)(input);
let ParsedItem(input, nano_timestamp) = match modifiers.precision {
modifier::UnixTimestampPrecision::Second => {
- n_to_m_digits::<1, 14, u128>(input)?.map(|val| val * Nanosecond.per(Second) as u128)
+ n_to_m_digits::<1, 14, u128>(input)?.map(|val| val * Nanosecond::per(Second) as u128)
}
modifier::UnixTimestampPrecision::Millisecond => n_to_m_digits::<1, 17, u128>(input)?
- .map(|val| val * Nanosecond.per(Millisecond) as u128),
+ .map(|val| val * Nanosecond::per(Millisecond) as u128),
modifier::UnixTimestampPrecision::Microsecond => n_to_m_digits::<1, 20, u128>(input)?
- .map(|val| val * Nanosecond.per(Microsecond) as u128),
+ .map(|val| val * Nanosecond::per(Microsecond) as u128),
modifier::UnixTimestampPrecision::Nanosecond => n_to_m_digits::<1, 23, _>(input)?,
};
@@ -331,3 +331,15 @@ pub(crate) fn parse_unix_timestamp(
_ => Some(ParsedItem(input, nano_timestamp as _)),
}
}
+
+/// Parse the `end` component, which represents the end of input. If any input is remaining, `None`
+/// is returned.
+pub(crate) const fn parse_end(input: &[u8], end: modifier::End) -> Option<ParsedItem<'_, ()>> {
+ let modifier::End {} = end;
+
+ if input.is_empty() {
+ Some(ParsedItem(input, ()))
+ } else {
+ None
+ }
+}