~humaid/hstatus

d595479f9110d176b59e330117f30d6593ff7c25 — Humaid AlQassimi a month ago e06f64a master
Use chrono-tz for proper timezones that respect DST
3 files changed, 94 insertions(+), 15 deletions(-)

M Cargo.lock
M Cargo.toml
M src/main.rs
M Cargo.lock => Cargo.lock +84 -2
@@ 49,6 49,28 @@ dependencies = [
]

[[package]]
name = "chrono-tz"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58549f1842da3080ce63002102d5bc954c7bc843d4f47818e642abdc36253552"
dependencies = [
 "chrono",
 "chrono-tz-build",
 "phf 0.10.1",
]

[[package]]
name = "chrono-tz-build"
version = "0.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db058d493fb2f65f41861bfed7e3fe6335264a9f0f92710cab5bdf01fef09069"
dependencies = [
 "parse-zoneinfo",
 "phf 0.10.1",
 "phf_codegen 0.10.0",
]

[[package]]
name = "futf"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 85,6 107,7 @@ name = "hstatus"
version = "0.1.0"
dependencies = [
 "chrono",
 "chrono-tz",
 "libc",
 "select",
 "signal-hook",


@@ 143,8 166,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a24f40fb03852d1cdd84330cddcaf98e9ec08a7b7768e952fad3b4cf048ec8fd"
dependencies = [
 "log",
 "phf",
 "phf_codegen",
 "phf 0.8.0",
 "phf_codegen 0.8.0",
 "string_cache",
 "string_cache_codegen",
 "tendril",


@@ 217,6 240,15 @@ dependencies = [
]

[[package]]
name = "parse-zoneinfo"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41"
dependencies = [
 "regex",
]

[[package]]
name = "phf"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 226,6 258,15 @@ dependencies = [
]

[[package]]
name = "phf"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259"
dependencies = [
 "phf_shared 0.10.0",
]

[[package]]
name = "phf_codegen"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 236,6 277,16 @@ dependencies = [
]

[[package]]
name = "phf_codegen"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd"
dependencies = [
 "phf_generator 0.10.0",
 "phf_shared 0.10.0",
]

[[package]]
name = "phf_generator"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 271,6 322,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096"
dependencies = [
 "siphasher",
 "uncased",
]

[[package]]


@@ 400,6 452,21 @@ dependencies = [
]

[[package]]
name = "regex"
version = "1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
dependencies = [
 "regex-syntax",
]

[[package]]
name = "regex-syntax"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"

[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 512,6 579,15 @@ dependencies = [
]

[[package]]
name = "uncased"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5baeed7327e25054889b9bd4f975f32e5f4c5d434042d59ab6cd4142c0a76ed0"
dependencies = [
 "version_check",
]

[[package]]
name = "unicode-xid"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 524,6 600,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"

[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"

[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"

M Cargo.toml => Cargo.toml +1 -0
@@ 9,6 9,7 @@ edition = "2018"
[dependencies]
x11 = { version = "2.18.2", features = ["xlib"] }
chrono = "0.4"
chrono-tz = "0.6"
libc = "0.2.68"
select = "0.6.0-alpha.1"
signal-hook = "0.2.1"

M src/main.rs => src/main.rs +9 -13
@@ 1,15 1,14 @@
extern crate chrono;
extern crate chrono_tz;
extern crate libc;
extern crate x11;
extern crate select;
extern crate signal_hook;

use signal_hook::{iterator::Signals, SIGINT, SIGHUP};

use select::document::Document;
use select::predicate::{Class, Predicate};

use chrono::prelude::*;
use chrono_tz::Asia::Dubai;
use chrono_tz::Europe::Helsinki;
use libc::{c_int, getloadavg};
use std::ffi::CString;
use std::fs::File;


@@ 19,7 18,7 @@ use std::sync::Arc;
use std::{string, thread, time};

/// System's name
const SYSTEM_NAME: &str = "humaid's system";
const SYSTEM_NAME: &str = "hsys";

/// DesktopStatus opens the X Display to allow changing the status (root
/// window) name.


@@ 82,18 81,15 @@ fn battery_item() -> Result<String, String> {
fn time_item() -> Result<String, String> {
    let mut res = String::new();
    let local: DateTime<Local> = Local::now();
    res.push_str("UK:");
    res.push_str("FI:");
    res.push_str(
        local
            .with_timezone(&chrono::FixedOffset::east(3600))
            .format("%I:%M")
            .to_string()
            .as_str(),
        Helsinki.from_utc_datetime(&local.naive_utc())
            .format("%I:%M").to_string().as_str(),
    );
    res.push(' ');
    res.push_str("AE:");
    res.push_str(local
        .with_timezone(&chrono::FixedOffset::east(4 * 3600))
    res.push_str(
	Dubai.from_utc_datetime(&local.naive_utc())
        .format("%I:%M %p %d-%m-%Y").to_string().as_str());
    res.push('|');
    Ok(res)