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

Stef Walter stefw at redhat.com
Thu Mar 19 07:35:18 PDT 2015


On 19.03.2015 15:17, David Herrmann wrote:
> Hi
> 
> On Thu, Mar 19, 2015 at 2:58 PM, Stef Walter <stefw at redhat.com> wrote:
>> On 19.03.2015 14:39, David Herrmann 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?
>>>
>>> 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.
> 
> But TimeUSec is UTC. If you retrieve "TimeUSec" and "Timezone", you
> can reconstruct the time offset yourself, without any further
> information, right?

No, the Timezone field is textual and unusable in a browser (unless you
reimplement all of /usr/share/zoneinfo in the browser).

>>> 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.
> 
> Why? This information should be the same on all machines, right? I
> don't see why the remote list is of any interest.

Because Cockpit is running in a browser, and accesses DBus from a
browser. But I guess we could implement our own DBus timedated2
interface which exposes the zoneinfo information. I just figured
timedated would be a natural place for such an API.

>> 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.
> 
> Yes, but it's the job of timedatectl to print information in the
> timezone of the remote host, not of the local host. It should retrieve
> the "Timezone" field and modify it's local timezone if you want the
> information to be relative to remote timezone, not the local timezone
> (which I'm not sure you really want).
> 
> What exactly do you mean with "full of invalid information"?

Example below. First set of timedatectl output is correct (since I SSH
and then invoke timedatectl) ... second set has lots of incorrect
fields, since timedatectl accesses timedated remotely:

$ ssh 192.168.11.155 timedatectl
      Local time: Fr 2015-03-20 01:31:41 AEDT
  Universal time: Do 2015-03-19 14:31:41 UTC
        RTC time: Do 2015-03-19 14:31:41
       Time zone: Australia/Tasmania (AEDT, +1100)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  So 2014-10-05 01:59:59 AEST
                  So 2014-10-05 03:00:00 AEDT
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  So 2015-04-05 02:59:59 AEDT
                  So 2015-04-05 02:00:00 AEST

$ timedatectl --host=192.168.11.155
      Local time: Do 2015-03-19 15:31:50 CET
  Universal time: Do 2015-03-19 14:31:50 UTC
        RTC time: Do 2015-03-19 14:31:50
       Time zone: Australia/Tasmania (CET, +0100)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  So 2014-10-26 02:59:59 CEST
                  So 2014-10-26 02:00:00 CET
 Next DST change: DST begins (the clock jumps one hour forward) at
                  So 2015-03-29 01:59:59 CET
                  So 2015-03-29 03:00:00 CEST



In particular the following fields are incorrect in the second set of
output:

      Local time: Do 2015-03-19 15:31:50 CET
       Time zone: Australia/Tasmania (CET, +0100)
 Last DST change: DST ended at
                  So 2014-10-26 02:59:59 CEST
                  So 2014-10-26 02:00:00 CET
 Next DST change: DST begins (the clock jumps one hour forward) at
                  So 2015-03-29 01:59:59 CET
                  So 2015-03-29 03:00:00 CEST


Cheers,

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/e429d875/attachment.sig>


More information about the systemd-devel mailing list