@@ -1,6 +1,6 @@ | |||||
[package] | [package] | ||||
name = "utcnow" | name = "utcnow" | ||||
version = "1.5.0" | |||||
version = "1.5.1" | |||||
authors = ["Jonathan Strong <jonathan.strong@gmail.com>"] | authors = ["Jonathan Strong <jonathan.strong@gmail.com>"] | ||||
edition = "2021" | edition = "2021" | ||||
@@ -1,21 +1,45 @@ | |||||
```console | ```console | ||||
utcnow 1.0.0 | |||||
Jonathan Strong <jonathan.strong@gmail.com> | |||||
$ utcnow -h | |||||
utcnow 1.5.0 | |||||
Jonathan Strong <jonathan.strong@gmail.com> | |||||
current time in utc with non-cryptic interface. | current time in utc with non-cryptic interface. | ||||
for your own safety and well-being, local time functionality is not provided. | |||||
$ utcnow | |||||
>> 2023-08-31T18:20:06.190019513Z | |||||
$ utcnow -R 1693505148834000000 | |||||
>> 2023-08-31T18:05:48.834000000Z | |||||
$ utcnow -U 2023-08-31T18:05:48.834000000Z | |||||
>> 1693505148834000000 | |||||
default output format is rfc3339 with trailing 'Z', e.g. '1999-12-31T23:59:59.999999999Z' | |||||
$ utcnow --unix | |||||
>> 1693506028080252547 | |||||
$ utcnow --millis | |||||
>> 2023-08-31T18:20:14.672Z | |||||
$ utcnow --unix --millis | |||||
>> 1693506584321 | |||||
USAGE: | USAGE: | ||||
utcnow [FLAGS] | |||||
utcnow [FLAGS] [OPTIONS] | |||||
FLAGS: | FLAGS: | ||||
-E, --est display in us/eastern timezone | |||||
-h, --help help | -h, --help help | ||||
-m, --millis display unix timestamp in milliseconds, instead of default nanoseconds | |||||
-0, --null terminate displayed time with null character instead of newline | |||||
-r, --rfc2822 display in rfc2822 format | -r, --rfc2822 display in rfc2822 format | ||||
-s, --seconds display unix timestamp in seconds, instead of default nanoseconds | -s, --seconds display unix timestamp in seconds, instead of default nanoseconds | ||||
-t, --timespec display as <sec>,<nsec> | -t, --timespec display as <sec>,<nsec> | ||||
-u, --unix display elapsed nanoseconds since 1970-01-01T00:00:00Z | -u, --unix display elapsed nanoseconds since 1970-01-01T00:00:00Z | ||||
-V, --version version | -V, --version version | ||||
OPTIONS: | |||||
-U, --rfc3339-to-unix <rfc3339-to-unix> parse rfc3339 timestamp and display it as a unix timestamp | |||||
-R, --unix-to-rfc3339 <unix-to-rfc3339> convert integer unix timestamp (nanoseconds precision) to datetime in | |||||
rfc3339 format. combine with --seconds or --millis to parse a seconds | |||||
timestamp with alternate precison | |||||
``` | ``` |
@@ -1,4 +1,5 @@ | |||||
#![allow(unused)] | #![allow(unused)] | ||||
use std::str::FromStr; | use std::str::FromStr; | ||||
use chrono::{DateTime, Utc, NaiveDateTime, TimeZone}; | use chrono::{DateTime, Utc, NaiveDateTime, TimeZone}; | ||||
@@ -31,8 +32,8 @@ fn main() { | |||||
let args: clap::ArgMatches = clap::App::new("utcnow") | let args: clap::ArgMatches = clap::App::new("utcnow") | ||||
.author("Jonathan Strong <jonathan.strong@gmail.com>") | .author("Jonathan Strong <jonathan.strong@gmail.com>") | ||||
.version(clap::crate_version!()) | .version(clap::crate_version!()) | ||||
.about("\ncurrent time in utc with non-cryptic interface.\n\n\ | |||||
default output format is rfc3339 with trailing 'Z', e.g. '1999-12-31T23:59:59.999999999Z'") | |||||
//.about("current time in utc with non-cryptic interface") | |||||
.about(LONG_HELP) | |||||
.help_message("help") | .help_message("help") | ||||
.version_message("version") | .version_message("version") | ||||
.arg(clap::Arg::with_name("unix") | .arg(clap::Arg::with_name("unix") | ||||
@@ -78,7 +79,7 @@ fn main() { | |||||
.short("R") | .short("R") | ||||
.alias("unix-to-utc") | .alias("unix-to-utc") | ||||
.help("convert integer unix timestamp (nanoseconds precision) to datetime \ | .help("convert integer unix timestamp (nanoseconds precision) to datetime \ | ||||
in rfc3339 format. combine with --seconds or --millis to parse a | |||||
in rfc3339 format. combine with --seconds or --millis to parse a \ | |||||
seconds timestamp with alternate precison") | seconds timestamp with alternate precison") | ||||
.takes_value(true) | .takes_value(true) | ||||
.required(false) | .required(false) | ||||
@@ -183,3 +184,27 @@ fn main() { | |||||
print!("{}{}", time_str, endline); | print!("{}{}", time_str, endline); | ||||
} | } | ||||
} | } | ||||
//const LONG_HELP: &str = include_str!("../long-help.txt"); | |||||
const LONG_HELP: &str = "current time in utc with non-cryptic interface. | |||||
$ utcnow | |||||
>> 2023-08-31T18:20:06.190019513Z | |||||
$ utcnow -R 1693505148834000000 | |||||
>> 2023-08-31T18:05:48.834000000Z | |||||
$ utcnow -U 2023-08-31T18:05:48.834000000Z | |||||
>> 1693505148834000000 | |||||
$ utcnow --unix | |||||
>> 1693506028080252547 | |||||
$ utcnow --millis | |||||
>> 2023-08-31T18:20:14.672Z | |||||
$ utcnow --unix --millis | |||||
>> 1693506584321"; | |||||