diff --git a/doc/gpg.texi b/doc/gpg.texi index ad6e46f1f..13d290bec 100644 --- a/doc/gpg.texi +++ b/doc/gpg.texi @@ -2942,6 +2942,14 @@ forth to @var{epoch} which is the number of seconds elapsed since the year If you suffix @var{epoch} with an exclamation mark (!), the system time will appear to be frozen at the specified time. +@item --full-timestrings +@opindex full-timestrings +Change the format of printed creation and expiration times from just +the date to the date and time. This is in general not useful and the +same information is anyway available in @option{--with-colons} mode. +These longer strings are also not well aligned with other printed +data. + @item --enable-progress-filter @opindex enable-progress-filter Enable certain PROGRESS status outputs. This option allows frontends diff --git a/g10/gpg.c b/g10/gpg.c index 2ac34c9c1..89e29fea2 100644 --- a/g10/gpg.c +++ b/g10/gpg.c @@ -431,6 +431,7 @@ enum cmd_and_opt_values oRequestOrigin, oNoSymkeyCache, oUseOnlyOpenPGPCard, + oFullTimestrings, oNoop }; @@ -902,6 +903,7 @@ static ARGPARSE_OPTS opts[] = { ARGPARSE_s_n (oNoAutostart, "no-autostart", "@"), ARGPARSE_s_n (oNoSymkeyCache, "no-symkey-cache", "@"), ARGPARSE_s_n (oUseKeyboxd, "use-keyboxd", "@"), + ARGPARSE_s_n (oFullTimestrings, "full-timestrings", "@"), /* Options to override new security defaults. */ ARGPARSE_s_n (oAllowWeakKeySignatures, "allow-weak-key-signatures", "@"), @@ -3677,6 +3679,10 @@ main (int argc, char **argv) opt.flags.use_only_openpgp_card = 1; break; + case oFullTimestrings: + opt.flags.full_timestrings = 1; + break; + case oNoop: break; default: diff --git a/g10/import.c b/g10/import.c index 911d0989c..5b50b722b 100644 --- a/g10/import.c +++ b/g10/import.c @@ -1411,7 +1411,7 @@ impex_filter_getval (void *cookie, const char *propname) } else if (!strcmp (propname, "sig_created_d")) { - result = datestr_from_sig (sig); + result = dateonlystr_from_sig (sig); } else if (!strcmp (propname, "sig_algo")) { @@ -1454,7 +1454,7 @@ impex_filter_getval (void *cookie, const char *propname) } else if (!strcmp (propname, "key_created_d")) { - result = datestr_from_pk (pk); + result = dateonlystr_from_pk (pk); } else if (!strcmp (propname, "expired")) { diff --git a/g10/keydb.h b/g10/keydb.h index 764cce98d..96b22eef2 100644 --- a/g10/keydb.h +++ b/g10/keydb.h @@ -533,7 +533,9 @@ unsigned nbits_from_pk( PKT_public_key *pk ); char *mk_datestr (char *buffer, size_t bufsize, u32 timestamp); #define MK_DATESTR_SIZE 11 +const char *dateonlystr_from_pk (PKT_public_key *pk); const char *datestr_from_pk( PKT_public_key *pk ); +const char *dateonlystr_from_sig( PKT_signature *sig ); const char *datestr_from_sig( PKT_signature *sig ); const char *expirestr_from_pk( PKT_public_key *pk ); const char *expirestr_from_sig( PKT_signature *sig ); diff --git a/g10/keyid.c b/g10/keyid.c index e6298e5da..573958e39 100644 --- a/g10/keyid.c +++ b/g10/keyid.c @@ -679,7 +679,7 @@ mk_datestr (char *buffer, size_t bufsize, u32 timestamp) * Format is: yyyy-mm-dd */ const char * -datestr_from_pk (PKT_public_key *pk) +dateonlystr_from_pk (PKT_public_key *pk) { static char buffer[MK_DATESTR_SIZE]; @@ -687,14 +687,36 @@ datestr_from_pk (PKT_public_key *pk) } +/* Same as dateonlystr_from_pk but with a global option a full iso + * timestamp is returned. In this case it shares a static buffer with + * isotimestamp(). */ const char * -datestr_from_sig (PKT_signature *sig ) +datestr_from_pk (PKT_public_key *pk) +{ + if (opt.flags.full_timestrings) + return isotimestamp (pk->timestamp); + else + return dateonlystr_from_pk (pk); +} + + +const char * +dateonlystr_from_sig (PKT_signature *sig ) { static char buffer[MK_DATESTR_SIZE]; return mk_datestr (buffer, sizeof buffer, sig->timestamp); } +const char * +datestr_from_sig (PKT_signature *sig ) +{ + if (opt.flags.full_timestrings) + return isotimestamp (sig->timestamp); + else + return dateonlystr_from_sig (sig); +} + const char * expirestr_from_pk (PKT_public_key *pk) @@ -703,6 +725,10 @@ expirestr_from_pk (PKT_public_key *pk) if (!pk->expiredate) return _("never "); + + if (opt.flags.full_timestrings) + return isotimestamp (pk->expiredate); + return mk_datestr (buffer, sizeof buffer, pk->expiredate); } @@ -714,6 +740,10 @@ expirestr_from_sig (PKT_signature *sig) if (!sig->expiredate) return _("never "); + + if (opt.flags.full_timestrings) + return isotimestamp (sig->expiredate); + return mk_datestr (buffer, sizeof buffer, sig->expiredate); } @@ -725,6 +755,10 @@ revokestr_from_pk( PKT_public_key *pk ) if(!pk->revoked.date) return _("never "); + + if (opt.flags.full_timestrings) + return isotimestamp (pk->revoked.date); + return mk_datestr (buffer, sizeof buffer, pk->revoked.date); } diff --git a/g10/options.h b/g10/options.h index e80d3ead0..4f190a1bc 100644 --- a/g10/options.h +++ b/g10/options.h @@ -248,6 +248,7 @@ struct /* Force the use of the OpenPGP card and do not allow the use of * another card. */ unsigned int use_only_openpgp_card:1; + unsigned int full_timestrings:1; } flags; /* Linked list of ways to find a key if the key isn't on the local