[Interest] Getting the timezone from Qt?

Lorn Potter lorn.potter at gmail.com
Tue Jul 31 05:43:02 CEST 2012


On 31/07/2012, at 1:28 PM, Nikos Chantziaras wrote:

> On 30/07/12 10:36, Konrad Rosenbaum wrote:
>> On Sunday 29 July 2012 22:30:32 Nikos Chantziaras wrote:
>>> [...] I'm looking for /etc/timezone and
>>> /etc/localtime.  In case the latter is a symlink, it's possible to get
>>> the timezone from the path string.
>> 
>> You are right of course - I should remember to read my own code properly.
>> However, /etc/localtime is usually not a symlink. If you are missing
>> /etc/timezone, you can also try /usr/local/etc/timezone (that's the default
>> location where the timezone library installs itself on a system that does not
>> have it per default).
> 
> I wonder if it's possible to deduce the timezone from the system's UTC 
> offset?  The offset can be determined through gmtime() and localtime(), 
> both in C89 so nothing platform-specific here:

If it were that easy, we wouldn't need the extensive tz database. :)




More information about the Interest mailing list