mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
Reviewed-on: https://forgejo.ellis.link/continuwuation/continuwuity/pulls/1136 Co-authored-by: Odd E. Ebbesen <git@oddware.net> Co-committed-by: Odd E. Ebbesen <git@oddware.net>
This commit is contained in:
committed by
Jade Ellis
parent
910a3182f7
commit
cb7875e479
@@ -126,3 +126,24 @@ pub enum Unit {
|
||||
Micros(u128),
|
||||
Nanos(u128),
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Copy, Debug)]
|
||||
pub enum TimeDirection {
|
||||
Before,
|
||||
After,
|
||||
}
|
||||
|
||||
/// Checks if `item_time` is before or after `time_boundary`.
|
||||
/// If both times are the same, it will return true for both directions, as the
|
||||
/// matching is inclusive.
|
||||
#[must_use]
|
||||
pub fn is_within_bounds(
|
||||
item_time: SystemTime,
|
||||
time_boundary: SystemTime,
|
||||
direction: TimeDirection,
|
||||
) -> bool {
|
||||
match direction {
|
||||
| TimeDirection::Before => item_time <= time_boundary,
|
||||
| TimeDirection::After => item_time >= time_boundary,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user