[Interest] Getting the timezone from Qt?

Konrad Rosenbaum konrad at silmor.de
Mon Jul 30 09:36:17 CEST 2012

On Sunday 29 July 2012 22:30:32 Nikos Chantziaras wrote:
> On 29/07/12 14:15, Konrad Rosenbaum wrote:
> > On Saturday 28 July 2012, Nikos Chantziaras wrote:
> >> But thank you very much for the pointer anyway.  At least I can look at
> >> that code to get an idea about how to get the needed info from the
> >> system :-)
> > 
> > src/tzsys*.cpp :-)
> > 
> > The unix variant should work on Mac as well and pretty much on any
> > Linux/Unix based system. It simply reads the "TZ" environment variable.
> That variable doesn't exist here.  So 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 just checked my Android phone (a Galaxy Nexus with Android 4.1): I can't 
find the time zone info there - it is not in any of the numerous etc 
directories or in an environment variable, you have to use the Android Java 
API or call "getprop persist.sys.timezone" (with QProcess, the output will be 
the time zone in "Europe/Berlin" format).

I'll set myself a reminder to check my Mac in the evening.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120730/bef9ad3b/attachment.sig>

More information about the Interest mailing list