Discussion:
[Question] timezones in timers
(too old to reply)
Ivan Kurnosov
2017-09-04 21:41:06 UTC
Permalink
Raw Message
Hi,

was it even considered initially to have proper timezones support in timers?

Or perhaps it is somewhere in the roadmap?

In particular, I'm speaking of `[Timer] OnCalendar`
--
With best regards, Ivan Kurnosov
Lennart Poettering
2017-09-05 07:11:19 UTC
Permalink
Raw Message
Post by Ivan Kurnosov
Hi,
was it even considered initially to have proper timezones support in timers?
Or perhaps it is somewhere in the roadmap?
In particular, I'm speaking of `[Timer] OnCalendar`
You mean as in explicitly per-unit configurable timezones?

It's nasty to do, since Linux APIs for that aren't really
existent. But it's not impossible to do, but so far nobody put
together a patch.

Lennart
--
Lennart Poettering, Red Hat
Ivan Kurnosov
2017-09-06 09:58:51 UTC
Permalink
Raw Message
I've started working on it (as a crazy experiment for myself primarily)

At the moment I added support for timezones (IANA) to the `CalendarSpec`,
the parser and the formatter.

https://github.com/zerkms/systemd/commit/367325ae7a2c4df2c0513e8bb8e992
5aaf24feef
Post by Ivan Kurnosov
Post by Ivan Kurnosov
Hi,
was it even considered initially to have proper timezones support in
timers?
Post by Ivan Kurnosov
Or perhaps it is somewhere in the roadmap?
In particular, I'm speaking of `[Timer] OnCalendar`
You mean as in explicitly per-unit configurable timezones?
It's nasty to do, since Linux APIs for that aren't really
existent. But it's not impossible to do, but so far nobody put
together a patch.
Lennart
--
Lennart Poettering, Red Hat
--
With best regards, Ivan Kurnosov
Mantas Mikulėnas
2017-09-06 10:18:05 UTC
Permalink
Raw Message
Post by Ivan Kurnosov
I've started working on it (as a crazy experiment for myself primarily)
At the moment I added support for timezones (IANA) to the `CalendarSpec`,
the parser and the formatter.
https://github.com/zerkms/systemd/commit/367325ae7a2c4df2c05
13e8bb8e9925aaf24feef
systemd actually used to have code for parsing *tzdata files* (and showing
DST information in timedatectl); you might want to find that in Git.
--
Mantas Mikulėnas <***@gmail.com>
Lennart Poettering
2017-09-06 13:25:20 UTC
Permalink
Raw Message
Post by Mantas Mikulėnas
Post by Ivan Kurnosov
I've started working on it (as a crazy experiment for myself primarily)
At the moment I added support for timezones (IANA) to the `CalendarSpec`,
the parser and the formatter.
https://github.com/zerkms/systemd/commit/367325ae7a2c4df2c05
13e8bb8e9925aaf24feef
systemd actually used to have code for parsing *tzdata files* (and showing
DST information in timedatectl); you might want to find that in Git.
While it did parse that I don't think we should go that route
here. When converting local time into unix time and back we really
should let the libc deal with that, and not replicate that. it's not
pretty to do this in libc, as there's no way to do time calculation in
a non-default timezone except by manipulating env vars, but it's
doable, as long as we do this out-of-process...

Lennart
--
Lennart Poettering, Red Hat
Ivan Kurnosov
2017-09-06 20:12:33 UTC
Permalink
Raw Message
I'm doing it with the libc and doing it out of the process:

https://github.com/zerkms/systemd/blob/d09815ef6df4705e06bd0b3a276c4cbd8630859f/src/basic/calendarspec.c#L902

I believe parsing is portable standard C with libc and time conversion will
be very similar to that.
Post by Ivan Kurnosov
Post by Mantas Mikulėnas
Post by Ivan Kurnosov
I've started working on it (as a crazy experiment for myself primarily)
At the moment I added support for timezones (IANA) to the
`CalendarSpec`,
Post by Mantas Mikulėnas
Post by Ivan Kurnosov
the parser and the formatter.
https://github.com/zerkms/systemd/commit/367325ae7a2c4df2c05
13e8bb8e9925aaf24feef
systemd actually used to have code for parsing *tzdata files* (and
showing
Post by Mantas Mikulėnas
DST information in timedatectl); you might want to find that in Git.
While it did parse that I don't think we should go that route
here. When converting local time into unix time and back we really
should let the libc deal with that, and not replicate that. it's not
pretty to do this in libc, as there's no way to do time calculation in
a non-default timezone except by manipulating env vars, but it's
doable, as long as we do this out-of-process...
Lennart
--
Lennart Poettering, Red Hat
--
With best regards, Ivan Kurnosov
Ivan Kurnosov
2017-09-09 09:16:31 UTC
Permalink
Raw Message
Hi,

I've implemented support for timezones in timers (at least I am not sure if
there are some other places that need some changes).

Here is a diff of what I've committed so far:
https://github.com/systemd/systemd/compare/master...zerkms:TIMER_TIMEZONE

In the very bottom in the tests file you may see what is supported and how.
In short:

the IANA timezone name are supported. Basically, any timezone from the
`timedatectl list-timezones` output is supported.

The most basic example of the timer:

2017-09-09 20:42:00 Pacific/Auckland


Implementation takes into account standard/summer time change.

Implementation might be improved further via a small refactoring to remove
the `CalendarSpec::utc` field, since it effectively is not necessary now,
given that one may use `spec->timezone = "UTC";` instead.

I'm looking for your feedback,

thanks.
Post by Ivan Kurnosov
https://github.com/zerkms/systemd/blob/d09815ef6df4705e06bd0b3a276c4c
bd8630859f/src/basic/calendarspec.c#L902
I believe parsing is portable standard C with libc and time conversion
will be very similar to that.
Post by Ivan Kurnosov
Post by Mantas Mikulėnas
Post by Ivan Kurnosov
I've started working on it (as a crazy experiment for myself
primarily)
Post by Mantas Mikulėnas
Post by Ivan Kurnosov
At the moment I added support for timezones (IANA) to the
`CalendarSpec`,
Post by Mantas Mikulėnas
Post by Ivan Kurnosov
the parser and the formatter.
https://github.com/zerkms/systemd/commit/367325ae7a2c4df2c05
13e8bb8e9925aaf24feef
systemd actually used to have code for parsing *tzdata files* (and
showing
Post by Mantas Mikulėnas
DST information in timedatectl); you might want to find that in Git.
While it did parse that I don't think we should go that route
here. When converting local time into unix time and back we really
should let the libc deal with that, and not replicate that. it's not
pretty to do this in libc, as there's no way to do time calculation in
a non-default timezone except by manipulating env vars, but it's
doable, as long as we do this out-of-process...
Lennart
--
Lennart Poettering, Red Hat
--
With best regards, Ivan Kurnosov
--
With best regards, Ivan Kurnosov
Lennart Poettering
2017-09-10 09:06:18 UTC
Permalink
Raw Message
Post by Ivan Kurnosov
Hi,
I've implemented support for timezones in timers (at least I am not sure if
there are some other places that need some changes).
https://github.com/systemd/systemd/compare/master...zerkms:TIMER_TIMEZONE
In the very bottom in the tests file you may see what is supported and how.
the IANA timezone name are supported. Basically, any timezone from the
`timedatectl list-timezones` output is supported.
2017-09-09 20:42:00 Pacific/Auckland
Implementation takes into account standard/summer time change.
Implementation might be improved further via a small refactoring to remove
the `CalendarSpec::utc` field, since it effectively is not necessary now,
given that one may use `spec->timezone = "UTC";` instead.
I'm looking for your feedback,
If you are confident that your code is somewhat complete now, please
submit it as PR on github, that's how we usually track submissions and
do codereview. it doesn't matter if you are a little bit unsure about
your code, or super confident, it's all handled through the PR
scheme. That way, everybody who works on systemd will get notified
about your code, the CI analyzes your code and we can do our review.

Thank you,

Lennart
--
Lennart Poettering, Red Hat
Loading...