From 694fe68059cd60ec754f2f6801672e82b74222a5 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Thu, 7 Nov 2024 11:46:15 +0000 Subject: [PATCH] Format start and end times in capture metadata. --- Cargo.lock | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/ui/mod.rs | 4 +++- 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 756e925a..725f307b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,6 +28,21 @@ dependencies = [ "version_check", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.86" @@ -399,6 +414,18 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "windows-targets 0.52.5", +] + [[package]] name = "concurrent-queue" version = "2.5.0" @@ -1152,6 +1179,29 @@ dependencies = [ "thiserror", ] +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "idna" version = "0.5.0" @@ -1590,6 +1640,7 @@ dependencies = [ "bytemuck", "bytemuck_derive", "byteorder_slice", + "chrono", "crc", "ctor", "dark-light", @@ -2462,6 +2513,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.5", +] + [[package]] name = "windows-sys" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index 78533458..125227a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,6 +57,7 @@ hidreport = "0.4.1" hut = "0.2.1" byteorder_slice = "3.0.0" merge = "0.1.0" +chrono = { version = "0.4.38", default-features = false, features = ["clock"] } [dev-dependencies] serde = { version = "1.0.196", features = ["derive"] } diff --git a/src/ui/mod.rs b/src/ui/mod.rs index e9808e06..0042ed7f 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -16,6 +16,7 @@ use std::net::TcpListener; use std::sync::Mutex; use anyhow::{Context as ErrorContext, Error, bail}; +use chrono::{DateTime, Local}; use bytemuck::bytes_of; use gtk::gio::{ @@ -1594,7 +1595,8 @@ fn show_metadata() -> Result<(), Error> { ("End time", &meta.end_time), ] { let text = field - .map(|s| format!("{s:?}")) + .map(|s| format!("{}", + DateTime::::from(s).format("%c"))) .unwrap_or(NONE.to_string()); add_field(row, name, &text); }