[systemd-devel] [PATCH] timedated: Add a LocalOffset property for timezone offset

Lennart Poettering lennart at poettering.net
Sun Mar 22 22:32:46 PDT 2015


On Thu, 19.03.15 14:39, David Herrmann (dh.herrmann at gmail.com) wrote:

> Hmm, so this is a convenience call. You could just set tm.tm_zone
> locally and use mktime() with the value retrieved by "Timezone"? Yeah,
> the time-api is awful with global variables, but that's not really our
> fault, is it?

This would not work, as struct tm's .tm_zone field is not sufficient
to indicate a timezone. The code would have to set $TZ and call tzset().

Given the simplicity of this I'd probably just merge Stef's
patch... It *is* kinda nice given that the timezone database is
constantly updated and having this exposed on the bus so that it is
accessible remotely has the benefit that you get the actual timezone
information in effect on the remote system, and not a possible
out-of-date timezone from the local database. If you follow what I mean...

> 
> I'm not really against this bus-call, but I also don't see the point.
> There's much more information in a timezone file than the offset, so
> why expose the offset but not the other data?
> 
> Thanks
> David
> 
> >  static int property_get_ntp_sync(
> >                  sd_bus *bus,
> >                  const char *path,
> > @@ -440,7 +456,8 @@ static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata, s
> >                     LOG_MESSAGE("Changed time zone to '%s'.", c->zone),
> >                     NULL);
> >
> > -        sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "Timezone", NULL);
> > +        sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1",
> > +                                       "Timezone", "LocalOffset", NULL);
> >
> >          return sd_bus_reply_method_return(m, NULL);
> >  }
> > @@ -666,6 +683,7 @@ static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus
> >  static const sd_bus_vtable timedate_vtable[] = {
> >          SD_BUS_VTABLE_START(0),
> >          SD_BUS_PROPERTY("Timezone", "s", NULL, offsetof(Context, zone), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> > +        SD_BUS_PROPERTY("LocalOffset", "t", property_get_local_offset, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> >          SD_BUS_PROPERTY("LocalRTC", "b", bus_property_get_bool, offsetof(Context, local_rtc), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> >          SD_BUS_PROPERTY("CanNTP", "b", bus_property_get_bool, offsetof(Context, can_ntp), 0),
> >          SD_BUS_PROPERTY("NTP", "b", bus_property_get_bool, offsetof(Context, use_ntp), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> > --
> > 2.3.3
> >
> > _______________________________________________
> > systemd-devel mailing list
> > systemd-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/systemd-devel
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list