diff options
author | J William Piggott | 2017-10-15 02:37:11 +0200 |
---|---|---|
committer | J William Piggott | 2017-11-10 22:34:55 +0100 |
commit | 4111bb3ab5f406ee381a3807385af59fe33b28f3 (patch) | |
tree | d03f85ab061bfade57c03c716e5226048fcdc8af /sys-utils | |
parent | lib/timeutils: add get_gmtoff() (diff) | |
download | kernel-qcow2-util-linux-4111bb3ab5f406ee381a3807385af59fe33b28f3.tar.gz kernel-qcow2-util-linux-4111bb3ab5f406ee381a3807385af59fe33b28f3.tar.xz kernel-qcow2-util-linux-4111bb3ab5f406ee381a3807385af59fe33b28f3.zip |
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 <elseifthen@gmx.com>
Diffstat (limited to 'sys-utils')
-rw-r--r-- | sys-utils/dmesg.c | 4 | ||||
-rw-r--r-- | sys-utils/hwclock.c | 6 | ||||
-rw-r--r-- | sys-utils/lsipc.c | 2 | ||||
-rw-r--r-- | sys-utils/rfkill.c | 10 |
4 files changed, 7 insertions, 15 deletions
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index 9fdc1d8a7..bdd50b474 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -840,9 +840,7 @@ static char *iso_8601_time(struct dmesg_control *ctl, struct dmesg_record *rec, .tv_usec = rec->tv.tv_usec }; - if (strtimeval_iso(&tv, ISO_8601_DATE|ISO_8601_TIME|ISO_8601_COMMAUSEC| - ISO_8601_TIMEZONE, - buf, bufsz) != 0) + if (strtimeval_iso(&tv, ISO_TIMESTAMP_COMMA_T, buf, bufsz) != 0) return NULL; return buf; diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index 3ac43efee..c93a5fd65 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -554,11 +554,9 @@ set_hardware_clock_exact(const struct hwclock_control *ctl, static int display_time(struct timeval hwctime) { - char buf[ISO_8601_BUFSIZ]; + char buf[ISO_BUFSIZ]; - if (strtimeval_iso(&hwctime, ISO_8601_DATE|ISO_8601_TIME|ISO_8601_DOTUSEC| - ISO_8601_TIMEZONE|ISO_8601_SPACE, - buf, sizeof(buf))) { + if (strtimeval_iso(&hwctime, ISO_TIMESTAMP_DOT, buf, sizeof(buf))) { warnx(_("iso-8601 format overflow")); return EXIT_FAILURE; } diff --git a/sys-utils/lsipc.c b/sys-utils/lsipc.c index e99c861ab..4b3b0c92d 100644 --- a/sys-utils/lsipc.c +++ b/sys-utils/lsipc.c @@ -451,7 +451,7 @@ static char *make_time(int mode, time_t time) strtime_short(&time, &now, 0, buf, sizeof(buf)); break; case TIME_ISO: - strtime_iso(&time, ISO_8601_DATE|ISO_8601_TIME|ISO_8601_TIMEZONE, buf, sizeof(buf)); + strtime_iso(&time, ISO_TIMESTAMP_T, buf, sizeof(buf)); break; default: errx(EXIT_FAILURE, _("unsupported time type")); diff --git a/sys-utils/rfkill.c b/sys-utils/rfkill.c index c9559ef48..75804ad41 100644 --- a/sys-utils/rfkill.c +++ b/sys-utils/rfkill.c @@ -223,7 +223,7 @@ static int rfkill_event(void) { struct rfkill_event event; struct timeval tv; - char date_buf[ISO_8601_BUFSIZ]; + char date_buf[ISO_BUFSIZ]; struct pollfd p; int fd, n; @@ -253,12 +253,8 @@ static int rfkill_event(void) continue; gettimeofday(&tv, NULL); - strtimeval_iso(&tv, - ISO_8601_DATE | - ISO_8601_TIME | - ISO_8601_COMMAUSEC | - ISO_8601_TIMEZONE | - ISO_8601_SPACE, date_buf, sizeof(date_buf)); + strtimeval_iso(&tv, ISO_TIMESTAMP_COMMA, date_buf, + sizeof(date_buf)); printf("%s: idx %u type %u op %u soft %u hard %u\n", date_buf, event.idx, event.type, event.op, event.soft, event.hard); |