From 4111bb3ab5f406ee381a3807385af59fe33b28f3 Mon Sep 17 00:00:00 2001 From: J William Piggott Date: Sat, 14 Oct 2017 20:37:11 -0400 Subject: lib/timeutils: add common ISO timestamp masks * Start the ISO format flags at bit 0 instead of bit 1. * Remove unnecessary _8601 from ISO format flag names to avoid line wrapping and to ease readability. * ISO timestamps have date-time-timzone in common, so move the TIMEZONE flag to bit 2 causing all timestamp masks to have the first three bits set and the last four bits as timestamp 'options'. * Change the 'SPACE' flag to a 'T' flag, because it makes the code and comments more concise. * Add common ISO timestamp masks. * Implement the ISO timestamp masks in all applicable code using the strxxx_iso() functions. Signed-off-by: J William Piggott --- login-utils/last.c | 2 +- login-utils/lslogins.c | 5 ++--- login-utils/utmpdump.c | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-) (limited to 'login-utils') diff --git a/login-utils/last.c b/login-utils/last.c index f2e8f834e..80d77d20b 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -349,7 +349,7 @@ static int time_formatter(int fmt, char *dst, size_t dlen, time_t *when) ret = rtrim_whitespace((unsigned char *) dst); break; case LAST_TIMEFTM_ISO8601: - ret = strtime_iso(when, ISO_8601_DATE|ISO_8601_TIME|ISO_8601_TIMEZONE, dst, dlen); + ret = strtime_iso(when, ISO_TIMESTAMP_T, dst, dlen); break; default: abort(); diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c index 1042b9b41..51033b01b 100644 --- a/login-utils/lslogins.c +++ b/login-utils/lslogins.c @@ -333,11 +333,10 @@ static char *make_time(int mode, time_t time) buf, sizeof(buf)); break; case TIME_ISO: - rc = strtime_iso(&time, ISO_8601_DATE|ISO_8601_TIME|ISO_8601_TIMEZONE, - buf, sizeof(buf)); + rc = strtime_iso(&time, ISO_TIMESTAMP_T, buf, sizeof(buf)); break; case TIME_ISO_SHORT: - rc = strtime_iso(&time, ISO_8601_DATE, buf, sizeof(buf)); + rc = strtime_iso(&time, ISO_DATE, buf, sizeof(buf)); break; default: errx(EXIT_FAILURE, _("unsupported time type")); diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c index 00c44b8db..5cc87834a 100644 --- a/login-utils/utmpdump.c +++ b/login-utils/utmpdump.c @@ -102,9 +102,7 @@ static void print_utline(struct utmpx *ut, FILE *out) tv.tv_sec = ut->ut_tv.tv_sec; tv.tv_usec = ut->ut_tv.tv_usec; - if (strtimeval_iso(&tv, - ISO_8601_DATE | ISO_8601_TIME | ISO_8601_COMMAUSEC | - ISO_8601_TIMEZONE | ISO_8601_GMTIME, time_string, + if (strtimeval_iso(&tv, ISO_TIMESTAMP_COMMA_GT, time_string, sizeof(time_string)) != 0) return; cleanse(ut->ut_id); -- cgit v1.2.3-55-g7522