pub trait ExtTime {
// Required methods
fn to_shorten(&self) -> String;
fn from_str(time_str: &str) -> Result<Time>;
fn sub_ext(&self, right: Time) -> Duration;
fn reset_minute(&self) -> Result<Time>;
fn is_same_minute(&self, other: &Time) -> bool;
fn is_between(&self, start: Time, end: Time) -> bool;
fn add_minutes(&self, minutes: i64) -> Time;
}Expand description
Extension trait for Time struct providing additional utility methods
Required Methods§
Sourcefn to_shorten(&self) -> String
fn to_shorten(&self) -> String
Format time as HH:MM, padding minutes with zero if needed
§Example
use time::macros::time;
use ext_time::ExtTime;
let t = time!(9:05);
assert_eq!(t.to_shorten(), "9:05");Sourcefn reset_minute(&self) -> Result<Time>
fn reset_minute(&self) -> Result<Time>
Reset seconds to zero, keeping hours and minutes
Sourcefn is_same_minute(&self, other: &Time) -> bool
fn is_same_minute(&self, other: &Time) -> bool
Check if two times are in the same minute
Sourcefn is_between(&self, start: Time, end: Time) -> bool
fn is_between(&self, start: Time, end: Time) -> bool
Check if time is between start and end (inclusive) Handles cross-day ranges (e.g., 23:00 to 01:00)
Sourcefn add_minutes(&self, minutes: i64) -> Time
fn add_minutes(&self, minutes: i64) -> Time
Add minutes to time, wrapping around midnight if needed
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.