Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 63 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ clap_mangen = "0.3.0"
crossterm = "0.29.0"
ctor = "1.0.0"
dirs = "7.0.0"
jiff = "0.2.15"
jiff = "1.0.0"
nix = { version = "0.31", default-features = false, features = ["process"] }
phf = "0.14.0"
phf_codegen = "0.14.0"
Expand Down
9 changes: 7 additions & 2 deletions src/uu/vmstat/src/picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ pub fn get_pickers(matches: &ArgMatches) -> Vec<Picker> {
pickers.push(concat_helper(
(
"-----timestamp-----".into(),
format!("{:>19}", jiff::Zoned::now().strftime("%Z").to_string()),
format!(
"{:>19}",
jiff::ZonedDateTime::now().strftime("%Z").to_string()
),
),
get_timestamp,
));
Expand Down Expand Up @@ -522,6 +525,8 @@ fn get_timestamp(
) -> Vec<(usize, String)> {
vec![(
10,
jiff::Zoned::now().strftime("%Y-%m-%d %H:%M:%S").to_string(),
jiff::ZonedDateTime::now()
.strftime("%Y-%m-%d %H:%M:%S")
.to_string(),
)]
}
12 changes: 6 additions & 6 deletions src/uu/w/src/w.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use clap::crate_version;
use clap::{Arg, ArgAction, Command};
#[cfg(target_os = "linux")]
use jiff::Zoned;
use jiff::ZonedDateTime;
#[cfg(target_os = "linux")]
use std::{collections::HashMap, fs, path::Path, time::SystemTime};
use std::{process, time::Duration};
Expand Down Expand Up @@ -128,8 +128,8 @@ fn format_time(time: String) -> Result<String, jiff::Error> {
t = t.drain(..time_offset).collect();
}
// If login time day is not current day, format like Sat16, or Fri06
let current_dt = Zoned::now();
let dt = Zoned::strptime("%Y-%m-%d %H:%M:%S%.f %:z", &t)?;
let current_dt = ZonedDateTime::now();
let dt = ZonedDateTime::strptime("%Y-%m-%d %H:%M:%S%.f %:z", &t)?;
if current_dt.day() == dt.day() {
Ok(dt.strftime("%H:%M").to_string())
} else {
Expand Down Expand Up @@ -412,18 +412,18 @@ mod tests {
fetch_cmdline, fetch_pcpu_time, fetch_terminal_number, format_time, format_time_elapsed,
format_uptime_procps, get_clock_tick,
};
use jiff::{SignedDuration, Zoned};
use jiff::{SignedDuration, ZonedDateTime};
use std::{fs, path::Path, process, time::Duration};

#[test]
fn test_format_time() {
let unix_epoc = Zoned::now()
let unix_epoc = ZonedDateTime::now()
.strftime("%Y-%m-%d %H:%M:%S%.6f %::z")
.to_string();
let unix_formatted = format_time(unix_epoc).unwrap();
assert!(unix_formatted.contains(':') && unix_formatted.chars().count() == 5);
// Test a date that is 5 days ago
let td = Zoned::now() - SignedDuration::from_secs(60 * 60 * 24 * 5);
let td = ZonedDateTime::now() - SignedDuration::from_secs(60 * 60 * 24 * 5);
// Pre-format time, so it's similar to how utmpx returns it
let pre_formatted = format!("{}", td.strftime("%Y-%m-%d %H:%M:%S%.6f %::z"));

Expand Down
Loading