Don't use system time
This commit is contained in:
parent
0d330126fe
commit
0d889b878e
2 changed files with 1 additions and 14 deletions
|
@ -5,7 +5,7 @@ authors = ["Smitty <me@smitop.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = { version = "0.4.19", features = ["std", "serde", "clock"], default-features = false }
|
chrono = { version = "0.4.19", features = ["std", "serde"], default-features = false }
|
||||||
serde = { version = "1.0.126", features = ["derive"] }
|
serde = { version = "1.0.126", features = ["derive"] }
|
||||||
json = "0.12.4"
|
json = "0.12.4"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
|
|
@ -135,19 +135,6 @@ impl Entity {
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The amount of days that the entity was in operations. For animals, this is lifespan.
|
|
||||||
/// For corporations and other legal entities it's the time between formation and dissolution.
|
|
||||||
pub fn timespan(&self) -> Option<u64> {
|
|
||||||
let start = self.start_time()?;
|
|
||||||
let end = self.end_time().unwrap_or_else(Utc::now);
|
|
||||||
let days = end.signed_duration_since(start).num_days();
|
|
||||||
if days < 0 {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(days as u64)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_json_string(mut json: json::JsonValue) -> String {
|
fn get_json_string(mut json: json::JsonValue) -> String {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue