add in a time library
This commit is contained in:
parent
919e0312cb
commit
74162b19f3
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -273,6 +273,13 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"versioning",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.5.9"
|
version = "0.5.9"
|
||||||
|
|
|
@ -14,6 +14,7 @@ members = [
|
||||||
"libraries/trash_manifest",
|
"libraries/trash_manifest",
|
||||||
"libraries/versioning",
|
"libraries/versioning",
|
||||||
"libraries/table",
|
"libraries/table",
|
||||||
|
"libraries/time",
|
||||||
|
|
||||||
"programs/delete",
|
"programs/delete",
|
||||||
"programs/list",
|
"programs/list",
|
||||||
|
|
9
libraries/time/Cargo.toml
Normal file
9
libraries/time/Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "time"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
versioning = { path = "../versioning" }
|
37
libraries/time/src/lib.rs
Normal file
37
libraries/time/src/lib.rs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
|
use versioning::Version;
|
||||||
|
pub const VERSION: Version = Version::new(0, 1, 0);
|
||||||
|
|
||||||
|
pub struct Time {
|
||||||
|
pub secs: u64,
|
||||||
|
pub nanos: u32,
|
||||||
|
}
|
||||||
|
impl Time {
|
||||||
|
pub fn now() -> Time {
|
||||||
|
let secs = 0;
|
||||||
|
let nanos = 0;
|
||||||
|
Time { secs, nanos }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn elapsed(&self) -> TimeDuration {
|
||||||
|
let secs = 0;
|
||||||
|
let nanos = 0;
|
||||||
|
TimeDuration { secs, nanos }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct TimeDuration {
|
||||||
|
pub secs: u64,
|
||||||
|
pub nanos: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TimeDuration {
|
||||||
|
pub fn from_secs(secs: u64) -> TimeDuration {
|
||||||
|
TimeDuration { secs, nanos: 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn as_secs(&self) -> u64 {
|
||||||
|
self.secs
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue