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

Stef Walter stefw at redhat.com
Thu Mar 19 06:58:14 PDT 2015


On 19.03.2015 14:39, David Herrmann wrote:
> Hi
> 
> On Thu, Mar 19, 2015 at 11:24 AM, Stef Walter <stefw at redhat.com> wrote:
>> This property is in usec (like the TimeUSec property) and allows
>> retrieving the timezone offset for the machine. This is particularly
>> usable for remote callers.
>> ---
>>  src/timedate/timedated.c | 20 +++++++++++++++++++-
>>  1 file changed, 19 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
>> index ca771d5..e384b36 100644
>> --- a/src/timedate/timedated.c
>> +++ b/src/timedate/timedated.c
>> @@ -361,6 +361,22 @@ static int property_get_time(
>>          return sd_bus_message_append(reply, "t", now(CLOCK_REALTIME));
>>  }
>>
>> +static int property_get_local_offset(
>> +                sd_bus *bus,
>> +                const char *path,
>> +                const char *interface,
>> +                const char *property,
>> +                sd_bus_message *reply,
>> +                void *userdata,
>> +                sd_bus_error *error)
>> +{
>> +        struct tm *tm;
>> +        time_t dummy = 0;
>> +
>> +        assert_se(tm = localtime(&dummy));
>> +        return sd_bus_message_append(reply, "t", (uint64_t)(tm->tm_gmtoff * 1000000));
>> +}
>> +
> 
> 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?
> 
> I'm not really against this bus-call, but I also don't see the point.

In Cockpit we're running on a different machine, and accessing timedated
remotely. If this information is not available in timedated, we would
need to add another DBus service to expose this information.

Besides it fits in well with the TimeUSec property.

> There's much more information in a timezone file than the offset, so
> why expose the offset but not the other data?

I would like to be able to do 'timedatectl list-timezones' over DBus as
well.

Such work would allow timedatectl to work properly with the --host
argument. Currently the output of 'timedatectl status
--host=machine-in-another-timezone.example.com' is full of invalid
information.

Stef

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150319/48e50937/attachment.sig>


More information about the systemd-devel mailing list