lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 3 November 2014 16:28, Gé Weijers <ge@weijers.org> wrote:
The downside of this approach is that you end up processing a zoneinfo
file each time you just intend to call localtime/localtime_r.
Depending on the time zone that can take a substantial amount of time.
The zoneinfo files for Cairo, Chile and Jerusalem are over 8K on my
system.

To use tzset and localtime_r correctly in a multi-threaded environment
it is probably necessary to use a read/write lock or similar to make
sure no localtime_r call is in progress while tzset is parsing the
zoneinfo file.


This is why things like 'timedated' exist.
If you're on a system with it available, you can subscribe to the 'PropertyChanged' signal on the 'timezone' property, and react to it.
http://www.freedesktop.org/wiki/Software/systemd/timedated/