From: Kimmo Teerimaki Date: Tue, 26 May 2009 10:19:21 +0000 (+0300) Subject: Timezone offset. X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=daecedb5a74ae1de4f53da2697f325c046db88c6;hp=c084f87d1751151c7f9e913776796a40c5cd5cb9;p=qtmeetings Timezone offset. --- diff --git a/src/IO/Communication/MessagingUtils.cpp b/src/IO/Communication/MessagingUtils.cpp index 0f6e63e..f3db490 100644 --- a/src/IO/Communication/MessagingUtils.cpp +++ b/src/IO/Communication/MessagingUtils.cpp @@ -1,4 +1,5 @@ #include +#include #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" ) ); diff --git a/src/IO/Communication/MessagingUtils.h b/src/IO/Communication/MessagingUtils.h index b15a99b..29d9744 100644 --- a/src/IO/Communication/MessagingUtils.h +++ b/src/IO/Communication/MessagingUtils.h @@ -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;