diff options
author | Karel Zak | 2016-05-24 11:09:41 +0200 |
---|---|---|
committer | Karel Zak | 2016-05-24 11:09:41 +0200 |
commit | 3c6e7c5414a7235f8b4065900966f7fd87f53d3c (patch) | |
tree | d75fc6faaf9988311f07c43d9bab8789ffd74e0f /sys-utils/dmesg.c | |
parent | lslogins: use strtm_iso() (diff) | |
download | kernel-qcow2-util-linux-3c6e7c5414a7235f8b4065900966f7fd87f53d3c.tar.gz kernel-qcow2-util-linux-3c6e7c5414a7235f8b4065900966f7fd87f53d3c.tar.xz kernel-qcow2-util-linux-3c6e7c5414a7235f8b4065900966f7fd87f53d3c.zip |
dmesg: use strtimeval_iso()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/dmesg.c')
-rw-r--r-- | sys-utils/dmesg.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index cf9333141..978bed0b2 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -825,19 +825,18 @@ static char *short_ctime(struct tm *tm, char *buf, size_t bufsiz) } static char *iso_8601_time(struct dmesg_control *ctl, struct dmesg_record *rec, - char *buf, size_t bufsiz) + char *buf, size_t bufsz) { - struct tm tm; - size_t len; - record_localtime(ctl, rec, &tm); - if (strftime(buf, bufsiz, "%Y-%m-%dT%H:%M:%S", &tm) == 0) { - *buf = '\0'; - return buf; - } - len = strlen(buf); - snprintf(buf + len, bufsiz - len, ",%06ld", (long)rec->tv.tv_usec); - len = strlen(buf); - strftime(buf + len, bufsiz - len, "%z", &tm); + struct timeval tv = { + .tv_sec = ctl->boot_time.tv_sec + rec->tv.tv_sec, + .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) + return NULL; + return buf; } @@ -956,7 +955,7 @@ static void print_record(struct dmesg_control *ctl, (long)rec->tv.tv_usec, record_count_delta(ctl, rec)); break; case DMESG_TIMEFTM_ISO8601: - ctl->indent = printf("%s ", iso_8601_time(ctl, rec, buf, sizeof(buf))); + printf("%s ", iso_8601_time(ctl, rec, buf, sizeof(buf))); break; default: abort(); |