mirror of
https://github.com/nushell/nushell
synced 2025-01-12 13:19:01 +00:00
Move uptime to being a duration value (#1573)
This commit is contained in:
parent
8e7e8c17e1
commit
fbddc12c02
1 changed files with 2 additions and 13 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue