pub struct Timespan(/* private fields */);Expand description
Represents an elapsed span of time
Implementations§
Source§impl Timespan
impl Timespan
Sourcepub fn from_nanos(nanos: i64) -> Self
pub fn from_nanos(nanos: i64) -> Self
Creates a Timespan from the specified number of nanoseconds.
Examples found in repository?
examples/working_with_time.rs (line 12)
7fn main() {
8 let t = Timestamp::from(SystemTime::now());
9 println!("{} nanos from unix epoch", t.as_nanos_unix());
10 println!("{} nanos from 1 Jan 2000 (KDB epoch)", t.as_raw());
11
12 let ts = Timespan::from_nanos(60_000_000_000);
13 let ts2 = Timespan::from_secs(60);
14 let ts3 = Timespan::try_from(Duration::from_secs(60)).unwrap();
15 assert_eq!(ts, ts2);
16 assert_eq!(ts, ts3);
17
18 let d = Date::new(2020, 2, 12);
19 assert_eq!(d.as_raw(), 20 * 365 + 5 + 31 + 12 - 1); // Days from 1 Jan 2000
20}Sourcepub fn from_micros(micros: i64) -> Self
pub fn from_micros(micros: i64) -> Self
Creates a Timespan from the specified number of microseconds.
Sourcepub fn from_millis(millis: i64) -> Self
pub fn from_millis(millis: i64) -> Self
Creates a Timespan from the specified number of milliseconds.
Sourcepub fn from_secs(millis: i64) -> Self
pub fn from_secs(millis: i64) -> Self
Creates a Timespan from the specified number of seconds.
Examples found in repository?
examples/working_with_time.rs (line 13)
7fn main() {
8 let t = Timestamp::from(SystemTime::now());
9 println!("{} nanos from unix epoch", t.as_nanos_unix());
10 println!("{} nanos from 1 Jan 2000 (KDB epoch)", t.as_raw());
11
12 let ts = Timespan::from_nanos(60_000_000_000);
13 let ts2 = Timespan::from_secs(60);
14 let ts3 = Timespan::try_from(Duration::from_secs(60)).unwrap();
15 assert_eq!(ts, ts2);
16 assert_eq!(ts, ts3);
17
18 let d = Date::new(2020, 2, 12);
19 assert_eq!(d.as_raw(), 20 * 365 + 5 + 31 + 12 - 1); // Days from 1 Jan 2000
20}Trait Implementations§
impl Copy for Timespan
impl Eq for Timespan
impl StructuralPartialEq for Timespan
Auto Trait Implementations§
impl Freeze for Timespan
impl RefUnwindSafe for Timespan
impl Send for Timespan
impl Sync for Timespan
impl Unpin for Timespan
impl UnwindSafe for Timespan
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