Move uptime to being a duration value (#1573)

This commit is contained in:
Jonathan Turner 2020-04-11 19:40:56 +12:00 committed by GitHub
parent 8e7e8c17e1
commit fbddc12c02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -97,20 +97,9 @@ async fn host(tag: Tag) -> Value {
// Uptime // Uptime
if let Ok(uptime) = uptime_result { if let Ok(uptime) = uptime_result {
let mut uptime_dict = TaggedDictBuilder::with_capacity(&tag, 4); let uptime = uptime.get::<time::second>().round() as u64;
let uptime = uptime.get::<time::second>().round() as i64; dict.insert_untagged("uptime", UntaggedValue::duration(uptime));
let days = uptime / (60 * 60 * 24);
let hours = (uptime - days * 60 * 60 * 24) / (60 * 60);
let minutes = (uptime - days * 60 * 60 * 24 - hours * 60 * 60) / 60;
let seconds = uptime % 60;
uptime_dict.insert_untagged("days", UntaggedValue::int(days));
uptime_dict.insert_untagged("hours", UntaggedValue::int(hours));
uptime_dict.insert_untagged("mins", UntaggedValue::int(minutes));
uptime_dict.insert_untagged("secs", UntaggedValue::int(seconds));
dict.insert_value("uptime", uptime_dict);
} }
// Sessions // Sessions