]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
dmesg: use subsecond granularity in iso format
authorThomas Weißschuh <thomas@t-8ch.de>
Sat, 21 Jan 2023 00:44:14 +0000 (00:44 +0000)
committerThomas Weißschuh <thomas@t-8ch.de>
Tue, 24 Jan 2023 16:04:55 +0000 (16:04 +0000)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
sys-utils/dmesg.c
tests/expected/dmesg/indentation

index fdf0f4631441640e852797ae2eae22ab0cae9be6..45075e50bd1fc0b1b3da4f4234df64c2ad3d75d7 100644 (file)
@@ -878,10 +878,10 @@ 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 bufsz)
 {
-       struct timeval tv = {
-               .tv_sec = ctl->boot_time.tv_sec + ctl->suspended_time / USEC_PER_SEC + rec->tv.tv_sec,
-               .tv_usec = rec->tv.tv_usec
-       };
+       struct timeval tv = usec_to_timeval(
+               timeval_to_usec(&ctl->boot_time) + ctl->suspended_time +
+               timeval_to_usec(&rec->tv)
+       );
 
        if (strtimeval_iso(&tv, ISO_TIMESTAMP_COMMA_T, buf, bufsz) != 0)
                return NULL;
index e1b2770d1c89492296e7899348b709188a506195..dc08810c0a8334df0d15f7e19a3b5c7eeaea937e 100644 (file)
@@ -28,8 +28,8 @@ lines
 [Fri Feb 13 23:31:32 2009] two
                            new
                            lines
-2009-02-13T23:31:31,000000+00:00 new
+2009-02-13T23:31:31,123456+00:00 new
                                  line
-2009-02-13T23:31:32,000000+00:00 two
+2009-02-13T23:31:32,123456+00:00 two
                                  new
                                  lines