Browse Source

adds --est flag

tags/v1.4.0
Jonathan Strong 2 years ago
parent
commit
19624631b5
3 changed files with 201 additions and 9 deletions
  1. +179
    -1
      Cargo.lock
  2. +1
    -0
      Cargo.toml
  3. +21
    -8
      src/main.rs

+ 179
- 1
Cargo.lock View File

@@ -1,5 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3

[[package]]
name = "ansi_term"
version = "0.11.0"
@@ -32,6 +34,12 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"

[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "chrono"
version = "0.4.11"
@@ -43,6 +51,28 @@ dependencies = [
"time",
]

[[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",
]

[[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",
"phf_codegen",
]

[[package]]
name = "clap"
version = "2.33.0"
@@ -58,6 +88,17 @@ dependencies = [
"vec_map",
]

[[package]]
name = "getrandom"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
dependencies = [
"cfg-if",
"libc",
"wasi",
]

[[package]]
name = "hermit-abi"
version = "0.1.8"
@@ -92,12 +133,127 @@ dependencies = [
"autocfg",
]

[[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.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259"
dependencies = [
"phf_shared",
]

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

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

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

[[package]]
name = "ppv-lite86"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"

[[package]]
name = "rand"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
dependencies = [
"libc",
"rand_chacha",
"rand_core",
"rand_hc",
]

[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
]

[[package]]
name = "rand_core"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [
"getrandom",
]

[[package]]
name = "rand_hc"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
dependencies = [
"rand_core",
]

[[package]]
name = "redox_syscall"
version = "0.1.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"

[[package]]
name = "regex"
version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
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 = "siphasher"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a86232ab60fa71287d7f2ddae4a7073f6b7aac33631c3015abb556f08c6d0a3e"

[[package]]
name = "strsim"
version = "0.8.0"
@@ -124,6 +280,15 @@ dependencies = [
"winapi",
]

[[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-width"
version = "0.1.7"
@@ -132,9 +297,10 @@ checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"

[[package]]
name = "utcnow"
version = "1.2.0"
version = "1.3.0"
dependencies = [
"chrono",
"chrono-tz",
"clap",
"libc",
]
@@ -145,6 +311,18 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"

[[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.10.2+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"

[[package]]
name = "winapi"
version = "0.3.8"


+ 1
- 0
Cargo.toml View File

@@ -8,5 +8,6 @@ edition = "2018"

[dependencies]
chrono = "0.4"
chrono-tz = "0.6"
clap = "2"
libc = "0.2.68"

+ 21
- 8
src/main.rs View File

@@ -32,7 +32,6 @@ fn main() {
.author("Jonathan Strong <jonathan.strong@gmail.com>")
.version(clap::crate_version!())
.about("\ncurrent time in utc with non-cryptic interface.\n\n\
for your own safety and well-being, local time functionality is not provided.\n\n\
default output format is rfc3339 with trailing 'Z', e.g. '1999-12-31T23:59:59.999999999Z'")
.help_message("help")
.version_message("version")
@@ -92,6 +91,12 @@ fn main() {
.takes_value(true)
.required(false)
.conflicts_with_all(&["unix", "unix-to-rfc3339", "rfc2822", "timespec"]))
.arg(clap::Arg::with_name("est-tz")
.long("est")
.short("E")
.help("display in us/eastern timezone")
.takes_value(false)
.conflicts_with_all(&["unix", "millis", "seconds", "timespec"]))
.get_matches();

@@ -150,14 +155,22 @@ fn main() {
}


} else if args.is_present("rfc2822") { // display rfc2822
print!("{}{}", timespec_to_utc(sec, nsec).to_rfc2822(), endline);
} else {
let time = timespec_to_utc(sec, nsec);

let time = if args.is_present("est-tz") {
time.with_timezone(&chrono_tz::US::Eastern)
} else {
time.with_timezone(&chrono_tz::UTC)
};

let time_str = if args.is_present("rfc2822") { // display rfc2822
time.to_rfc2822()
} else {
//time.to_rfc3339()
format!("{:?}", time)
};

} else { // display rfc3339
// Debug view is iso format / rfc3339 that we want
// Display has spaces - no go
// to_rfc3339 uses +00:00 instead of Z, which I don't like
print!("{:?}{}", timespec_to_utc(sec, nsec), endline);
print!("{}{}", time_str, endline);
}
}

Loading…
Cancel
Save