utils.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <qdatetime.h>
00022
00023 extern "C" {
00024 #include <ical.h>
00025 }
00026
00027 #include "utils.h"
00028
00031 QDomElement addElement( QDomDocument& doc, QDomNode& node, const QString& ns, const QString& tag )
00032 {
00033 QDomElement el = doc.createElementNS( ns, tag );
00034 node.appendChild( el );
00035 return el;
00036 }
00037
00042 QDomElement addElement( QDomDocument& doc, QDomNode& node, const QString& ns, const QString& tag, const QString& text )
00043 {
00044 QDomElement el = doc.createElementNS( ns, tag );
00045 QDomText textnode = doc.createTextNode( text );
00046 el.appendChild( textnode );
00047 node.appendChild( el );
00048 return el;
00049 }
00050
00051 QDateTime utcAsZone( const QDateTime& utc, const QString& timeZoneId )
00052 {
00053 QDateTime epoch;
00054 epoch.setTime_t( 0 );
00055 time_t v = epoch.secsTo( utc );
00056 struct icaltimetype tt = icaltime_from_timet( v, 0 );
00057 int offset = icaltime_utc_offset( tt, timeZoneId.local8Bit() );
00058 return utc.addSecs( offset );
00059 }
00060
00061 QDateTime zoneAsUtc( const QDateTime& zone, const QString& timeZoneId )
00062 {
00063 QDateTime epoch;
00064 epoch.setTime_t( 0 );
00065 time_t v = epoch.secsTo( zone );
00066 struct icaltimetype tt = icaltime_from_timet( v, 0 );
00067 int offset = icaltime_utc_offset( tt, timeZoneId.local8Bit() );
00068 return zone.addSecs( - offset );
00069 }
00070
00071 KURL toDAV( const KURL& url ) {
00072 KURL result( url );
00073 if ( result.protocol() == "http" )
00074 result.setProtocol( "webdav" );
00075 else if ( result.protocol() == "https" )
00076 result.setProtocol( "webdavs" );
00077 return result;
00078 }
00079
00080 KURL* toDAV( const KURL* url ) {
00081 KURL* result = new KURL( *url );
00082 if ( result->protocol() == "http" )
00083 result->setProtocol( "webdav" );
00084 else if ( result->protocol() == "https" )
00085 result->setProtocol( "webdavs" );
00086 return result;
00087 }
00088
This file is part of the documentation for libkpimexchange Library Version 3.2.2.