From 85baaeed28f347994518d03ae60b5e9060fd4642 Mon Sep 17 00:00:00 2001 From: konrad Date: Sun, 11 Jul 2010 17:09:13 +0000 Subject: [PATCH] make system local TZ detection public git-svn-id: https://silmor.de/svn/softmagic/tzone/trunk@556 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- tzdata.cpp | 12 +++++++++++- tzdata.h | 3 +++ 2 files changed, 14 insertions(+), 1 deletions(-) diff --git a/tzdata.cpp b/tzdata.cpp index 02f76a4..33d8241 100644 --- a/tzdata.cpp +++ b/tzdata.cpp @@ -326,6 +326,7 @@ QString TimeStamp::defaultZone() bool TimeStamp::setDefaultZone(QString z) { //is z empty? + z=z.trimmed(); if(z==""){ //try to get my own default QSettings set; @@ -334,7 +335,7 @@ bool TimeStamp::setDefaultZone(QString z) } //still empty: try to guess system default if(z==""){ - z=systemDefaultDiscover(); + z=systemDefaultDiscover().trimmed(); } //if still empty: get current diff from UTC if(z==""){ @@ -417,3 +418,12 @@ bool TimeStamp::loadZone(QString zone) return tf.isValid(); } +QString TimeStamp::systemLocalZone() +{ + QString dz=defaultzone; + setDefaultZone(""); + QString r=defaultzone; + setDefaultZone(dz); + return r; +} + diff --git a/tzdata.h b/tzdata.h index 0bd1667..72c1819 100644 --- a/tzdata.h +++ b/tzdata.h @@ -294,6 +294,9 @@ class TimeStamp /**Tries to load the given zone, returns true on success. Other than loading it this method does not do anything with the loaded zone, it just checks that it is available to time stamps.*/ static bool loadZone(QString zone); + + /**Tries to find the computers local time zone and returns it*/ + static QString systemLocalZone(); private: //the main measure of time: the unix timestamp qint64 m_unix; -- 1.7.2.5