]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hwclock: use strtimeval_iso()
authorKarel Zak <kzak@redhat.com>
Tue, 24 May 2016 09:10:10 +0000 (11:10 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 24 May 2016 09:10:10 +0000 (11:10 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/hwclock.c

index 8241d81b9d50b70f20c5bf7752d61bb322089c7b..e98c2c00faa95d88319c25c9bd29917a978e3326 100644 (file)
@@ -80,6 +80,7 @@
 #include "pathnames.h"
 #include "strutils.h"
 #include "hwclock.h"
+#include "timeutils.h"
 
 #ifdef HAVE_LIBAUDIT
 #include <libaudit.h>
@@ -687,15 +688,12 @@ display_time(const bool hclock_valid, struct timeval hwctime)
                       "either invalid (e.g. 50th day of month) or beyond the range "
                       "we can handle (e.g. Year 2095)."));
        else {
-               struct tm lt;
-               int zhour, zmin;
-
-               lt = *localtime(&hwctime.tv_sec);
-               zhour = - timezone / 60 / 60;
-               zmin = labs(timezone / 60 % 60);
-               printf(_("%4d-%.2d-%.2d %02d:%02d:%02d.%06ld%+02d:%02d\n"),
-                      lt.tm_year + 1900, lt.tm_mon + 1, lt.tm_mday, lt.tm_hour,
-                      lt.tm_min, lt.tm_sec, (long)hwctime.tv_usec, zhour, zmin);
+               char buf[ISO_8601_BUFSIZ];
+
+               strtimeval_iso(&hwctime, ISO_8601_DATE|ISO_8601_TIME|ISO_8601_DOTUSEC|
+                                        ISO_8601_TIMEZONE|ISO_8601_SPACE,
+                                        buf, sizeof(buf));
+               printf("%s\n", buf);
        }
 }