Pergunta

Since the system /usr/share/zoneinfo database is updated fairly frequently, I would like to be able to load it (and reload it) dynamically in a very long running C++ program.

Now I know the standard library will use this database, but I doubt it offers dynamic reloading of it (or at least I couldn't find anything about it with Google.)

Is there any C or C++ library or code that I can use to do this?

Foi útil?

Solução

I'm an idiot. IANA which provides the zoneinfo database, also provides a library for working with it. Funnily enough I discovered this by reading the postgresql source code.

I'm not sure if this is sufficient, but it's public domain licensed so at the least I can pull it into my code and bend it to my needs.

Outras dicas

localtime et al use the timezone conversion information as set by tzset, so you would usually be able to reload that information by setting TZ to some value, calling tzset, setting it back and calling it again. This will work with glibc, but you should probably check on other platforms.

Otherwise, you're using some other non-Posix API to access the zoneinfo database, and you should look at the facilities that library has for reloading its data.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top