pub struct Time(/* private fields */);Expand description
Time it’s basically a milliseconds value it can mean certain time or duration of time
example)
use trading_toolkit::types::time::Time;
use std::time::{SystemTime, UNIX_EPOCH};
let now = Time::now().unwrap();
assert_eq!(
now.inner(),
SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(),
);
let days = 2;
let days_in_time = Time::from_days(days);
assert_eq!(days_in_time.inner(), (days as u128) * 24 * 60 * 60 * 1000 as u128);Implementations§
Source§impl Time
impl Time
Sourcepub fn now() -> Result<Self, SystemTimeError>
pub fn now() -> Result<Self, SystemTimeError>
return passed milliseconds as Time from UNIX_EPOCH(1970-01-01T00:00:00.000Z)
Sourcepub fn from_hours(hours: usize) -> Self
pub fn from_hours(hours: usize) -> Self
return duration of hours
Sourcepub fn from_minutes(minutes: usize) -> Self
pub fn from_minutes(minutes: usize) -> Self
return duration of minutes
Sourcepub fn from_seconds(seconds: usize) -> Self
pub fn from_seconds(seconds: usize) -> Self
return duration of seconds
Trait Implementations§
Source§impl AddAssign for Time
impl AddAssign for Time
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreSource§impl Ord for Time
impl Ord for Time
Source§impl PartialOrd for Time
impl PartialOrd for Time
Source§impl SubAssign for Time
impl SubAssign for Time
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreimpl Copy for Time
impl Eq for Time
Auto Trait Implementations§
impl Freeze for Time
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnsafeUnpin for Time
impl UnwindSafe for Time
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more