From fbddc12c026ffca4e73c03495337ad88d737dfba Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sat, 11 Apr 2020 19:40:56 +1200 Subject: [PATCH] Move uptime to being a duration value (#1573) --- crates/nu_plugin_sys/src/sys.rs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/crates/nu_plugin_sys/src/sys.rs b/crates/nu_plugin_sys/src/sys.rs index 844a71150a..2c34dac5a1 100644 --- a/crates/nu_plugin_sys/src/sys.rs +++ b/crates/nu_plugin_sys/src/sys.rs @@ -97,20 +97,9 @@ async fn host(tag: Tag) -> Value { // Uptime if let Ok(uptime) = uptime_result { - let mut uptime_dict = TaggedDictBuilder::with_capacity(&tag, 4); + let uptime = uptime.get::().round() as u64; - let uptime = uptime.get::().round() as i64; - 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); + dict.insert_untagged("uptime", UntaggedValue::duration(uptime)); } // Sessions