[systemd-devel] [PATCH] timedatectl: fix when queried system has differn't timezone
Shawn Landden
shawn at churchofgit.com
Mon Mar 23 04:39:38 PDT 2015
Also allow getting time from time(2) when BUS_TRANSPORT_MACHINE.
---
src/timedate/timedatectl.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index 9e04f8f..7c9bd11 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -106,14 +106,17 @@ static void print_status_info(const StatusInfo *i) {
/* Enforce the values of /etc/localtime */
if (getenv("TZ")) {
- fprintf(stderr, "Warning: Ignoring the TZ variable. Reading the system's time zone setting only.\n\n");
+ fprintf(stderr, "Warning: Ignoring the TZ variable.\n\n");
unsetenv("TZ");
}
+ setenv("TZ", i->timezone, false);
+ tzset();
+
if (i->time != 0) {
sec = (time_t) (i->time / USEC_PER_SEC);
have_time = true;
- } else if (arg_transport == BUS_TRANSPORT_LOCAL) {
+ } else if (IN_SET(arg_transport, BUS_TRANSPORT_REMOTE, BUS_TRANSPORT_MACHINE)) {
sec = time(NULL);
have_time = true;
} else
--
2.2.1.209.g41e5f3a
More information about the systemd-devel
mailing list