From e4498adb1f38cd297b13a31659c1c12ccd5e498a Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Mon, 2 Mar 2020 14:58:15 -0800 Subject: [PATCH] Make block-time more human-readable (#8575) --- cli/src/cluster_query.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cli/src/cluster_query.rs b/cli/src/cluster_query.rs index 743978feea..518864593f 100644 --- a/cli/src/cluster_query.rs +++ b/cli/src/cluster_query.rs @@ -5,6 +5,7 @@ use crate::{ }, display::println_name_value, }; +use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc}; use clap::{value_t, value_t_or_exit, App, Arg, ArgMatches, SubCommand}; use console::{style, Emoji}; use indicatif::{ProgressBar, ProgressStyle}; @@ -454,7 +455,13 @@ pub fn process_leader_schedule(rpc_client: &RpcClient) -> ProcessResult { pub fn process_get_block_time(rpc_client: &RpcClient, slot: Slot) -> ProcessResult { let timestamp = rpc_client.get_block_time(slot)?; - Ok(timestamp.to_string()) + let result = format!( + "{} (UnixTimestamp: {})", + DateTime::::from_utc(NaiveDateTime::from_timestamp(timestamp, 0), Utc) + .to_rfc3339_opts(SecondsFormat::Secs, true), + timestamp + ); + Ok(result) } fn slot_to_human_time(slot: Slot) -> String {