Re: [systemd-devel] Specifying calendar events in an arbitrary timezone

2016-12-15 Thread Mantas Mikulėnas
Ah, systemd in fact had tzdata parsing code already – it was used by
tinedatectl to show DST info. Try to recover it from Git.

On Thu, Dec 15, 2016, 21:03 Ran Benita  wrote:

> On Thu, Dec 15, 2016 at 06:35:15PM +0100, Lennart Poettering wrote:
> > So yeah, we'd love to support this, but are waiting for a suitable API.
>
> I see, makes sense.
>
> Since new glibc API will probably be slow to come, if ever, it might
> make sense to circumvent it and go for the tzdata directly? It seems the
> format is described in tzfile(5), and the glibc code which handles it
> seems to be public domain as well: https://github.com/eggert/tz
> I don't have any experience with those APIs, though.
>
> If I get some time I'll try and see if such an approach is viable.
>
> Thanks!
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
-- 

Mantas Mikulėnas 
Sent from my phone
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Specifying calendar events in an arbitrary timezone

2016-12-15 Thread Ran Benita
On Thu, Dec 15, 2016 at 06:35:15PM +0100, Lennart Poettering wrote:
> So yeah, we'd love to support this, but are waiting for a suitable API.

I see, makes sense.

Since new glibc API will probably be slow to come, if ever, it might
make sense to circumvent it and go for the tzdata directly? It seems the
format is described in tzfile(5), and the glibc code which handles it
seems to be public domain as well: https://github.com/eggert/tz
I don't have any experience with those APIs, though.

If I get some time I'll try and see if such an approach is viable.

Thanks!
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Specifying calendar events in an arbitrary timezone

2016-12-15 Thread Lennart Poettering
On Thu, 15.12.16 17:52, Ran Benita (ran...@gmail.com) wrote:

> My question: is this not supported on purpose (because timezones suck),
> or because it's just not implemented/hard to implement?

Current systemd actually supports calendar events with timezone
specifications. However, the specified time zone must either be "UTC"
or identical to the one configured in /etc/localtime, which doesn't
make it particularly useful I guess (the reason we support this is so
that any timestamp we spit out can also be parsed againt as calendar
event specification, and out timestamps after all do include a
timezone specification).

We'd love to support any kind of timezone specifications, but glibc
does not offer a suitable API for that. We could change around the $TZ
env var all the time when doing time calculations, but that's just
awful.

For most locale-dependent function calls glibc nowadays provides
"locale_t" arguments in order to run them with a different locale. It
would be great if it had a matching "timezone_t" type or so which
would allow running time-specific functions with a different timezone.

So yeah, we'd love to support this, but are waiting for a suitable API.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Specifying calendar events in an arbitrary timezone

2016-12-15 Thread Ran Benita
I would like to schedule some timers to execute daily at a given time in
some given timezone. My use-case for this is:

- The server's local timezone is UTC - this is just good practice for
  various reasons, so I don't want to change that.

- For business reasons, the service I want to run needs to run at the
  given time in the given timezone. Since that timezone switches
  daylight saving twice a year, I cannot specify the time in UTC, since
  it will become 1 hour off when the local time changes.

systemd does not allow to specify a calendar event in a non-local,
non-UTC timezone. This is explictly specified in systemd.time(7):

Non-local timezones except for UTC are not supported.

My question: is this not supported on purpose (because timezones suck),
or because it's just not implemented/hard to implement?

If it's on purpose, I can relate - in a local timezone, the event can
occur 0, 1 or 2 times, which is not good. However, since systemd already
supports the local timezone, I think this battle is already lost. So we
can say that the behavior for an arbitrary timezone is the same as if it
were the local timezone.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel