Make block-time more human-readable (#8575)

This commit is contained in:
Tyera Eulberg 2020-03-02 14:58:15 -08:00 committed by GitHub
parent 42c5c59800
commit e4498adb1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -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::<Utc>::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 {