added three time option #574

This commit is contained in:
DustInDark
2022-06-08 18:50:30 +09:00
parent af9fed4d2e
commit 781117f206
3 changed files with 66 additions and 4 deletions

52
Cargo.lock generated
View File

@@ -568,6 +568,21 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foreign-types"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
dependencies = [
"foreign-types-shared",
]
[[package]]
name = "foreign-types-shared"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "form_urlencoded"
version = "1.0.1"
@@ -699,6 +714,7 @@ dependencies = [
"linked-hash-map",
"lock_api",
"num_cpus",
"openssl",
"pbr",
"prettytable-rs",
"quick-xml 0.23.0",
@@ -1103,12 +1119,47 @@ version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
[[package]]
name = "openssl"
version = "0.10.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e"
dependencies = [
"bitflags",
"cfg-if",
"foreign-types",
"libc",
"once_cell",
"openssl-macros",
"openssl-sys",
]
[[package]]
name = "openssl-macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "openssl-probe"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-src"
version = "111.20.0+1.1.1o"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92892c4f87d56e376e469ace79f1128fdaded07646ddf73aa0be4706ff712dec"
dependencies = [
"cc",
]
[[package]]
name = "openssl-sys"
version = "0.9.74"
@@ -1118,6 +1169,7 @@ dependencies = [
"autocfg",
"cc",
"libc",
"openssl-src",
"pkg-config",
"vcpkg",
]

View File

@@ -592,10 +592,17 @@ fn format_rfc<Tz: TimeZone>(time: &DateTime<Tz>) -> String
where
Tz::Offset: std::fmt::Display,
{
if configs::CONFIG.read().unwrap().args.is_present("rfc-2822") {
let time_args = &configs::CONFIG.read().unwrap().args;
if time_args.is_present("rfc-2822") {
time.to_rfc2822()
} else if configs::CONFIG.read().unwrap().args.is_present("rfc-3339") {
time.to_rfc3339()
} else if time_args.is_present("rfc-3339") {
time.format("%Y-%m-%d %H:%M:%S%.6f%:z").to_string()
} else if time_args.is_present("US-time") {
time.format("%m-%d-%Y %I:%M:%S%.3f %p %:z").to_string()
} else if time_args.is_present("US-military-time") {
time.format("%m-%d-%Y %H:%M:%S%.3f %:z").to_string()
} else if time_args.is_present("European-time") {
time.format("%d-%m-%Y %H:%M:%S%.3f %:z").to_string()
} else {
time.format("%Y-%m-%d %H:%M:%S%.3f %:z").to_string()
}

View File

@@ -87,7 +87,10 @@ fn build_app<'a>() -> ArgMatches<'a> {
--start-timeline [START_TIMELINE] 'Start time of the event logs to load. (Example: \"2018-11-28 12:00:00 +09:00\")'
--end-timeline [END_TIMELINE] 'End time of the event logs to load. (Example: \"2021-11-28 12:00:00 +09:00\")'
--rfc-2822 'Output date and time in RFC 2822 format. (Example: Mon, 07 Aug 2006 12:34:56 -0600)'
--rfc-3339 'Output date and time in RFC 3339 format. (Example: 2006-08-07T12:34:56.485214 -06:00)'
--rfc-3339 'Output date and time in RFC 3339 format. (Example: 2006-08-07 12:34:56.485214-06:00)'
--US-time 'Output date time in US time format. (Example: 08-07-2006 00:34:56.485 PM -6:00)'
--US-military-time 'Output date time in US military time format. (Example: 08-07-2006 12:34:56.485 -6:00)'
--European-time 'Output date time in European time format. (Example: 07-08-2006 12:34:56.485 +2:00)'
-U, --utc 'Output time in UTC format. (Default: local time)'
--no-color 'Disable color output.'
-t, --thread-number [NUMBER] 'Thread number. (Default: Optimal number for performance.)'