summaryrefslogtreecommitdiff
path: root/libopie/pim/otimezone.cpp
Side-by-side diff
Diffstat (limited to 'libopie/pim/otimezone.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/otimezone.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/libopie/pim/otimezone.cpp b/libopie/pim/otimezone.cpp
index b2bd3aa..34659c3 100644
--- a/libopie/pim/otimezone.cpp
+++ b/libopie/pim/otimezone.cpp
@@ -7,55 +7,64 @@
namespace {
QDateTime utcTime( time_t t) {
tm* broken = ::gmtime( &t );
QDateTime ret;
ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon +1, broken->tm_mday ) );
ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) );
return ret;
}
QDateTime utcTime( time_t t, const QString& zone) {
QCString org = ::getenv( "TZ" );
+#ifndef Q_OS_MACX // Following line causes bus errors on Mac
::setenv( "TZ", zone.latin1(), true );
::tzset();
tm* broken = ::localtime( &t );
::setenv( "TZ", org, true );
+#else
+#warning "Need a replacement for MacOSX!!"
+ tm* broken = ::localtime( &t );
+#endif
QDateTime ret;
ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon +1, broken->tm_mday ) );
ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) );
return ret;
}
time_t to_Time_t( const QDateTime& utc, const QString& str ) {
QDate d = utc.date();
QTime t = utc.time();
tm broken;
broken.tm_year = d.year() - 1900;
broken.tm_mon = d.month() - 1;
broken.tm_mday = d.day();
broken.tm_hour = t.hour();
broken.tm_min = t.minute();
broken.tm_sec = t.second();
QCString org = ::getenv( "TZ" );
+#ifndef Q_OS_MACX // Following line causes bus errors on Mac
::setenv( "TZ", str.latin1(), true );
::tzset();
time_t ti = ::mktime( &broken );
::setenv( "TZ", org, true );
-
+#else
+#warning "Need a replacement for MacOSX!!"
+ time_t ti = ::mktime( &broken );
+#endif
return ti;
}
}
OTimeZone::OTimeZone( const ZoneName& zone )
: m_name(zone) {
}
OTimeZone::~OTimeZone() {
}
bool OTimeZone::isValid()const {
return !m_name.isEmpty();
}