timedatectl: display RTCTimeUSec in UTC format

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.
This commit is contained in:
lzwind
2026-07-14 21:05:01 +08:00
committed by Luca Boccassi
parent 01e1303f9c
commit 2dcdbae4dd

View 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