summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimtimezone.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimtimezone.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimtimezone.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/libopie2/opiepim/core/opimtimezone.cpp b/libopie2/opiepim/core/opimtimezone.cpp
index fefceb5..5b32b1f 100644
--- a/libopie2/opiepim/core/opimtimezone.cpp
+++ b/libopie2/opiepim/core/opimtimezone.cpp
@@ -45,12 +45,13 @@ QDateTime utcTime( time_t t )
45 tm * broken = ::gmtime( &t ); 45 tm * broken = ::gmtime( &t );
46 QDateTime ret; 46 QDateTime ret;
47 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) ); 47 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) );
48 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); 48 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) );
49 return ret; 49 return ret;
50} 50}
51
51QDateTime utcTime( time_t t, const QString& zone ) 52QDateTime utcTime( time_t t, const QString& zone )
52{ 53{
53 QCString org = ::getenv( "TZ" ); 54 QCString org = ::getenv( "TZ" );
54#ifndef Q_OS_MACX // Following line causes bus errors on Mac 55#ifndef Q_OS_MACX // Following line causes bus errors on Mac
55 56
56 ::setenv( "TZ", zone.latin1(), true ); 57 ::setenv( "TZ", zone.latin1(), true );
@@ -67,12 +68,14 @@ QDateTime utcTime( time_t t, const QString& zone )
67 QDateTime ret; 68 QDateTime ret;
68 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) ); 69 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) );
69 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); 70 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) );
70 71
71 return ret; 72 return ret;
72} 73}
74
75
73time_t to_Time_t( const QDateTime& utc, const QString& str ) 76time_t to_Time_t( const QDateTime& utc, const QString& str )
74{ 77{
75 QDate d = utc.date(); 78 QDate d = utc.date();
76 QTime t = utc.time(); 79 QTime t = utc.time();
77 80
78 tm broken; 81 tm broken;
@@ -148,27 +151,26 @@ QDateTime OPimTimeZone::toDateTime( time_t t )
148/* 151/*
149 * convert dt to utc using zone.m_name 152 * convert dt to utc using zone.m_name
150 * convert utc -> timeZoneDT using this->m_name 153 * convert utc -> timeZoneDT using this->m_name
151 */ 154 */
152QDateTime OPimTimeZone::toDateTime( const QDateTime& dt, const OPimTimeZone& zone ) 155QDateTime OPimTimeZone::toDateTime( const QDateTime& dt, const OPimTimeZone& zone )
153{ 156{
154 time_t utc = to_Time_t( dt, zone.m_name ); 157 time_t utc = to_Time_t( dt, m_name );
155 owarn << "" << utc << " " << zone.m_name << "" << oendl; 158 return utcTime( utc, zone.m_name );
156 return utcTime( utc, m_name );
157} 159}
158 160
159 161
160time_t OPimTimeZone::fromDateTime( const QDateTime& time ) 162time_t OPimTimeZone::fromDateTime( const QDateTime& time )
161{ 163{
162 return to_Time_t( time, m_name ); 164 return to_Time_t( time, m_name );
163} 165}
164 166
165 167
166time_t OPimTimeZone::fromUTCDateTime( const QDateTime& time ) 168time_t OPimTimeZone::fromUTCDateTime( const QDateTime& time )
167{ 169{
168 return to_Time_t( time, "UTC" ); 170 return to_Time_t( time, "Europe/London" );
169} 171}
170 172
171 173
172OPimTimeZone OPimTimeZone::current() 174OPimTimeZone OPimTimeZone::current()
173{ 175{
174 QCString str = ::getenv( "TZ" ); 176 QCString str = ::getenv( "TZ" );
@@ -176,13 +178,13 @@ OPimTimeZone OPimTimeZone::current()
176 return zone; 178 return zone;
177} 179}
178 180
179 181
180OPimTimeZone OPimTimeZone::utc() 182OPimTimeZone OPimTimeZone::utc()
181{ 183{
182 return OPimTimeZone( "UTC" ); 184 return OPimTimeZone( "Europe/London" );
183} 185}
184 186
185 187
186QString OPimTimeZone::timeZone() const 188QString OPimTimeZone::timeZone() const
187{ 189{
188 return m_name; 190 return m_name;