KeyGenerationTime: remove formatted(); add to_datetime(); implement Display.
This commit is contained in:
parent
02b42081b9
commit
b668aebaba
2 changed files with 10 additions and 6 deletions
|
@ -252,11 +252,15 @@ impl KeyGenerationTime {
|
|||
self.0
|
||||
}
|
||||
|
||||
pub fn formatted(&self) -> String {
|
||||
pub fn to_datetime(&self) -> DateTime<Utc> {
|
||||
let d = UNIX_EPOCH + Duration::from_secs(self.get() as u64);
|
||||
let datetime = DateTime::<Utc>::from(d);
|
||||
DateTime::<Utc>::from(d)
|
||||
}
|
||||
}
|
||||
|
||||
datetime.format("%Y-%m-%d %H:%M:%S").to_string()
|
||||
impl Display for KeyGenerationTime {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.to_datetime())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -465,7 +465,7 @@ fn print_status(ident: Option<String>, verbose: bool) -> Result<()> {
|
|||
println!(" fingerprint: {}", fp.to_spaced_hex());
|
||||
}
|
||||
if let Some(kgt) = kgt.signature() {
|
||||
println! {" created: {}", kgt.formatted()};
|
||||
println! {" created: {}", kgt.to_datetime()};
|
||||
}
|
||||
println! {" algorithm: {}", open.algorithm_attributes(KeyType::Signing)?};
|
||||
if verbose {
|
||||
|
@ -480,7 +480,7 @@ fn print_status(ident: Option<String>, verbose: bool) -> Result<()> {
|
|||
println!(" fingerprint: {}", fp.to_spaced_hex());
|
||||
}
|
||||
if let Some(kgt) = kgt.decryption() {
|
||||
println! {" created: {}", kgt.formatted()};
|
||||
println! {" created: {}", kgt.to_datetime()};
|
||||
}
|
||||
println! {" algorithm: {}", open.algorithm_attributes(KeyType::Decryption)?};
|
||||
if verbose {
|
||||
|
@ -495,7 +495,7 @@ fn print_status(ident: Option<String>, verbose: bool) -> Result<()> {
|
|||
println!(" fingerprint: {}", fp.to_spaced_hex());
|
||||
}
|
||||
if let Some(kgt) = kgt.authentication() {
|
||||
println! {" created: {}", kgt.formatted()};
|
||||
println! {" created: {}", kgt.to_datetime()};
|
||||
}
|
||||
println! {" algorithm: {}", open.algorithm_attributes(KeyType::Authentication)?};
|
||||
if verbose {
|
||||
|
|
Loading…
Reference in a new issue