]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
timedatectl: display RTCTimeUSec in UTC format
authorlzwind <lzwind@users.noreply.github.com>
Tue, 14 Jul 2026 13:05:01 +0000 (21:05 +0800)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 14 Jul 2026 17:29:21 +0000 (18:29 +0100)
Fixes #39930

The RTCTimeUSec property was being displayed in local time format
when using 'timedatectl show', while 'timedatectl status' correctly
displayed it in UTC format. This inconsistency was due to the
bus_print_all_properties() function using TIMESTAMP_PRETTY style
for all timestamps, which formats in local time.

This fix adds special handling for RTCTimeUSec to use TIMESTAMP_UTC
style, ensuring consistent UTC display across both commands.

src/shared/bus-print-properties.c

index 431b33c100cdfa1208e1ef75352d50cfcab4e036..d2377ceb60b844db38aaf811176aabbc38a72683 100644 (file)
@@ -113,7 +113,11 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b
                         return r;
 
                 if (bus_property_is_timestamp(name))
-                        bus_print_property_value(name, expected_value, flags, FORMAT_TIMESTAMP(u));
+                        /* RTCTimeUSec should always be displayed in UTC, consistent with timedatectl status */
+                        if (streq(name, "RTCTimeUSec"))
+                                bus_print_property_value(name, expected_value, flags, FORMAT_TIMESTAMP_STYLE(u, TIMESTAMP_UTC));
+                        else
+                                bus_print_property_value(name, expected_value, flags, FORMAT_TIMESTAMP(u));
 
                 /* Managed OOM pressure default implies "unset" and use the default set in oomd.conf. Without
                  * this condition, we will print "infinity" which implies there is no limit on memory