diff --git a/Cargo.toml b/Cargo.toml index 2a3db26..c66ddf1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,3 +7,4 @@ edition = "2018" [dependencies] sys-info = "*" dbus = "*" +chrono = "*" diff --git a/src/main.rs b/src/main.rs index 7082aa1..0d7dc9c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,8 @@ +extern crate chrono; extern crate dbus; + use crate::dbus::blocking::stdintf::org_freedesktop_dbus::Properties; +use chrono::{DateTime, FixedOffset, Local, Utc}; use dbus::{arg, blocking::Connection}; use std::{env, fs, time::Duration}; use sys_info; @@ -153,9 +156,24 @@ fn format_time(sec: i64) -> String { result.to_string() } +fn get_time(utc: bool, mut format: &str) { + // Format reference: https://docs.rs/chrono/0.4.10/chrono/format/strftime/index.html + if format.len() == 0 { + format = "%H:%M"; + } + if utc { + let local_time = Local::now(); + let utc_time = DateTime::::from_utc(local_time.naive_utc(), Utc); + println!("{}", utc_time.format(format)); + } else { + let local_time = Local::now(); + println!("{}", local_time.format(format)); + } +} + fn main() { let args: Vec = env::args().collect(); - let help_text: &str = "Available commands -mb, -cb"; + let help_text: &str = "Available commands -mb, -cb, -tl