diff --git a/crates/nu-command/src/system/ps.rs b/crates/nu-command/src/system/ps.rs index 6f39061dab..cece41e56f 100644 --- a/crates/nu-command/src/system/ps.rs +++ b/crates/nu-command/src/system/ps.rs @@ -1,3 +1,5 @@ +#[cfg(target_os = "macos")] +use chrono::{Local, TimeZone}; #[cfg(windows)] use itertools::Itertools; use nu_engine::command_prelude::*; @@ -175,6 +177,10 @@ fn run_ps( #[cfg(target_os = "macos")] { record.push("cwd", Value::string(proc.cwd(), span)); + let timestamp = Local + .timestamp_nanos(proc.start_time * 1_000_000_000) + .into(); + record.push("start_time", Value::date(timestamp, span)); } } diff --git a/crates/nu-system/src/macos.rs b/crates/nu-system/src/macos.rs index e9b927c1fe..8d6ab59d4b 100644 --- a/crates/nu-system/src/macos.rs +++ b/crates/nu-system/src/macos.rs @@ -25,6 +25,7 @@ pub struct ProcessInfo { pub curr_res: Option, pub prev_res: Option, pub interval: Duration, + pub start_time: i64, } pub fn collect_proc(interval: Duration, _with_thread: bool) -> Vec { @@ -94,6 +95,7 @@ pub fn collect_proc(interval: Duration, _with_thread: bool) -> Vec let curr_time = Instant::now(); let interval = curr_time.saturating_duration_since(prev_time); let ppid = curr_task.pbsd.pbi_ppid as i32; + let start_time = curr_task.pbsd.pbi_start_tvsec as i64; let proc = ProcessInfo { pid, @@ -107,6 +109,7 @@ pub fn collect_proc(interval: Duration, _with_thread: bool) -> Vec curr_res, prev_res, interval, + start_time, }; ret.push(proc);