PGP Keyring: Display expiry dates in ISO format

This commit is contained in:
David Duque 2020-11-21 03:26:27 +00:00
parent 570a22903a
commit 392f05b975
No known key found for this signature in database
GPG key ID: 2F327738A3C0AE3A
2 changed files with 8 additions and 8 deletions

View file

@ -31,7 +31,7 @@ def key_representation(key):
"auth": skey.can_authenticate == 1,
"fpr": skey.fpr,
"expires": skey.expires if skey.expires != 0 else None,
"expires_date": datetime.datetime.utcfromtimestamp(skey.expires).strftime("%x") if skey.expires != 0 else None,
"expires_date": datetime.datetime.utcfromtimestamp(skey.expires).date().isoformat() if skey.expires != 0 else None,
"expires_days": (datetime.datetime.utcfromtimestamp(skey.expires) - now).days if skey.expires != 0 else None,
"expired": skey.expired == 1,
"algorithm": gpg.core.pubkey_algo_name(skey.pubkey_algo),

View file

@ -290,9 +290,9 @@ def run_pgp_checks(env, output):
else:
exp = datetime.datetime.utcfromtimestamp(sk.expires) # Our daemon key only has one subkey
if (exp - now).days < 10 and sk.expires != 0:
output.print_warning(f"The daemon's key ({k.fpr}) will expire soon, in {(exp - now).days} days on {exp.strftime('%x')}.")
output.print_warning(f"The daemon's key ({k.fpr}) will expire soon, in {(exp - now).days} days on {exp.date().soformat()}.")
else:
output.print_ok(f"The daemon's key ({k.fpr}) is good. It expires in {(exp - now).days} days on {exp.strftime('%x')}.")
output.print_ok(f"The daemon's key ({k.fpr}) is good. It expires in {(exp - now).days} days on {exp.date().isoformat()}.")
# Check imported keys
keys = get_imported_keys()