|
6 | 6 | use clap::crate_version; |
7 | 7 | use clap::{Arg, ArgAction, Command}; |
8 | 8 | #[cfg(target_os = "linux")] |
9 | | -use jiff::Zoned; |
| 9 | +use jiff::ZonedDateTime; |
10 | 10 | #[cfg(target_os = "linux")] |
11 | 11 | use std::{collections::HashMap, fs, path::Path, time::SystemTime}; |
12 | 12 | use std::{process, time::Duration}; |
@@ -128,8 +128,8 @@ fn format_time(time: String) -> Result<String, jiff::Error> { |
128 | 128 | t = t.drain(..time_offset).collect(); |
129 | 129 | } |
130 | 130 | // If login time day is not current day, format like Sat16, or Fri06 |
131 | | - let current_dt = Zoned::now(); |
132 | | - let dt = Zoned::strptime("%Y-%m-%d %H:%M:%S%.f %:z", &t)?; |
| 131 | + let current_dt = ZonedDateTime::now(); |
| 132 | + let dt = ZonedDateTime::strptime("%Y-%m-%d %H:%M:%S%.f %:z", &t)?; |
133 | 133 | if current_dt.day() == dt.day() { |
134 | 134 | Ok(dt.strftime("%H:%M").to_string()) |
135 | 135 | } else { |
@@ -412,18 +412,18 @@ mod tests { |
412 | 412 | fetch_cmdline, fetch_pcpu_time, fetch_terminal_number, format_time, format_time_elapsed, |
413 | 413 | format_uptime_procps, get_clock_tick, |
414 | 414 | }; |
415 | | - use jiff::{SignedDuration, Zoned}; |
| 415 | + use jiff::{SignedDuration, ZonedDateTime}; |
416 | 416 | use std::{fs, path::Path, process, time::Duration}; |
417 | 417 |
|
418 | 418 | #[test] |
419 | 419 | fn test_format_time() { |
420 | | - let unix_epoc = Zoned::now() |
| 420 | + let unix_epoc = ZonedDateTime::now() |
421 | 421 | .strftime("%Y-%m-%d %H:%M:%S%.6f %::z") |
422 | 422 | .to_string(); |
423 | 423 | let unix_formatted = format_time(unix_epoc).unwrap(); |
424 | 424 | assert!(unix_formatted.contains(':') && unix_formatted.chars().count() == 5); |
425 | 425 | // Test a date that is 5 days ago |
426 | | - let td = Zoned::now() - SignedDuration::from_secs(60 * 60 * 24 * 5); |
| 426 | + let td = ZonedDateTime::now() - SignedDuration::from_secs(60 * 60 * 24 * 5); |
427 | 427 | // Pre-format time, so it's similar to how utmpx returns it |
428 | 428 | let pre_formatted = format!("{}", td.strftime("%Y-%m-%d %H:%M:%S%.6f %::z")); |
429 | 429 |
|
|
0 commit comments