Timezone offset.
authorKimmo Teerimaki <kimmo.teerimaki@ixonos.com>
Tue, 26 May 2009 10:19:21 +0000 (13:19 +0300)
committerKimmo Teerimaki <kimmo.teerimaki@ixonos.com>
Tue, 26 May 2009 10:19:21 +0000 (13:19 +0300)
src/IO/Communication/MessagingUtils.cpp
src/IO/Communication/MessagingUtils.h

index 0f6e63e..f3db490 100644 (file)
@@ -1,4 +1,5 @@
 #include <QUrl>
+#include <time.h>
 
 #include "MessagingUtils.h"
 #include "Meeting.h"
@@ -868,8 +869,29 @@ int ReqMsgGetUserAvailability::setTimeZone()
                return MsgErrSomeError;
        }
        int err = MsgErrNoError;
+       
+       //QDateTime now = QDateTime::currentDateTime();
+       //int offsetMinutes =  (now.toTime_t() - QDateTime(now.toUTC().date(), QTime(now.toUTC().time().hour(), now.toUTC().time().minute())).toTime_t()) / 60;
+       
+       time_t rawtime;
+       tm *localTime;
+
+       time(&rawtime);
+       localTime = localtime(&rawtime);
+       
+       int offsetMinutes = localTime->tm_gmtoff / 60;
+       if (localTime->tm_isdst)
+               offsetMinutes -= 60;    // If DST is in use then reduce an hour from offset, because
+                                                               // DST will be added to the offset later and it already includes
+                                                               // DST. TODO: This is silly and must be changed if possible.
+                                                               // If you can get UTC offset without DST, use it here.
+       
+#ifdef MU_DEBUG
+       qDebug( "ReqMsgGetUserAvailability::setTimeZone - offset in minutes=%d", offsetMinutes );
+#endif
+       
        //TODO: timezone and daylight times to application configuration
-       setNodeValue( QString( "Bias" ), QString::number( -120 ), QDomNode::ElementNode, QString( "TimeZone" ) );
+       setNodeValue( QString( "Bias" ), QString::number( -offsetMinutes ), QDomNode::ElementNode, QString( "TimeZone" ) );
        setNodeValue( QString( "Bias" ), QString::number( 0 ), QDomNode::ElementNode, QString( "StandardTime" ) );
        setNodeValue( QString( "Time" ), QString( "03:00:00" ), QDomNode::ElementNode, QString( "StandardTime" ) );
        setNodeValue( QString( "DayOrder" ), QString::number( 5 ), QDomNode::ElementNode, QString( "StandardTime" ) );
index b15a99b..29d9744 100644 (file)
@@ -17,8 +17,8 @@
 #define ACTION_URL "http://schemas.microsoft.com/exchange/services/2006/messages/"
 
 //Set MessagingUtils Debug on/off
-//#define MU_DEBUG
-#undef MU_DEBUG
+#define MU_DEBUG
+//#undef MU_DEBUG
 
 class Meeting;
 class Room;