-rw-r--r-- | libkcal/vcalformat.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 9307f12..0ebd7d1 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -26,12 +26,13 @@ | |||
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qclipboard.h> | 27 | #include <qclipboard.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | 30 | ||
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | ||
32 | #include <kmessagebox.h> | 33 | #include <kmessagebox.h> |
33 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
34 | #include <klocale.h> | 35 | #include <klocale.h> |
35 | 36 | ||
36 | #include "vcc.h" | 37 | #include "vcc.h" |
37 | #include "vobject.h" | 38 | #include "vobject.h" |
@@ -43,12 +44,13 @@ | |||
43 | 44 | ||
44 | using namespace KCal; | 45 | using namespace KCal; |
45 | 46 | ||
46 | VCalFormat::VCalFormat() | 47 | VCalFormat::VCalFormat() |
47 | { | 48 | { |
48 | mCalendar = 0; | 49 | mCalendar = 0; |
50 | useLocalTime = false; | ||
49 | } | 51 | } |
50 | 52 | ||
51 | VCalFormat::~VCalFormat() | 53 | VCalFormat::~VCalFormat() |
52 | { | 54 | { |
53 | } | 55 | } |
54 | 56 | ||
@@ -163,30 +165,38 @@ bool VCalFormat::fromString( Calendar *calendar, const QString &text ) | |||
163 | 165 | ||
164 | deleteVObject( vcal ); | 166 | deleteVObject( vcal ); |
165 | 167 | ||
166 | return true; | 168 | return true; |
167 | } | 169 | } |
168 | 170 | ||
169 | QString VCalFormat::eventToString( Event * event, Calendar *calendar) | 171 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) |
170 | { | 172 | { |
173 | |||
171 | if ( !event ) return QString::null; | 174 | if ( !event ) return QString::null; |
175 | bool useL = useLocalTime; | ||
176 | useLocalTime = useLocal; | ||
172 | mCalendar = calendar; | 177 | mCalendar = calendar; |
173 | VObject *vevent = eventToVEvent( event ); | 178 | VObject *vevent = eventToVEvent( event ); |
174 | char *buf = writeMemVObject( 0, 0, vevent ); | 179 | char *buf = writeMemVObject( 0, 0, vevent ); |
175 | QString result( buf ); | 180 | QString result( buf ); |
176 | cleanVObject( vevent ); | 181 | cleanVObject( vevent ); |
182 | useLocalTime = useL; | ||
177 | return result; | 183 | return result; |
178 | } | 184 | } |
179 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar ) | 185 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) |
180 | { | 186 | { |
187 | |||
181 | if ( !todo ) return QString::null; | 188 | if ( !todo ) return QString::null; |
189 | bool useL = useLocalTime; | ||
190 | useLocalTime = useLocal; | ||
182 | mCalendar = calendar; | 191 | mCalendar = calendar; |
183 | VObject *vevent = eventToVTodo( todo ); | 192 | VObject *vevent = eventToVTodo( todo ); |
184 | char *buf = writeMemVObject( 0, 0, vevent ); | 193 | char *buf = writeMemVObject( 0, 0, vevent ); |
185 | QString result( buf ); | 194 | QString result( buf ); |
186 | cleanVObject( vevent ); | 195 | cleanVObject( vevent ); |
196 | useLocalTime = useL; | ||
187 | return result; | 197 | return result; |
188 | } | 198 | } |
189 | 199 | ||
190 | QString VCalFormat::toString( Calendar *calendar ) | 200 | QString VCalFormat::toString( Calendar *calendar ) |
191 | { | 201 | { |
192 | // TODO: Factor out VCalFormat::asString() | 202 | // TODO: Factor out VCalFormat::asString() |
@@ -1431,15 +1441,14 @@ QString VCalFormat::qDateToISO(const QDate &qd) | |||
1431 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) | 1441 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) |
1432 | { | 1442 | { |
1433 | QString tmpStr; | 1443 | QString tmpStr; |
1434 | 1444 | ||
1435 | ASSERT(qdt.date().isValid()); | 1445 | ASSERT(qdt.date().isValid()); |
1436 | ASSERT(qdt.time().isValid()); | 1446 | ASSERT(qdt.time().isValid()); |
1437 | if (zulu) { | 1447 | if (zulu && !useLocalTime ) { |
1438 | QDateTime tmpDT(qdt); | 1448 | QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); |
1439 | tmpDT = tmpDT.addSecs(60*(-mCalendar->getTimeZone())); // correct to GMT. | ||
1440 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", | 1449 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", |
1441 | tmpDT.date().year(), tmpDT.date().month(), | 1450 | tmpDT.date().year(), tmpDT.date().month(), |
1442 | tmpDT.date().day(), tmpDT.time().hour(), | 1451 | tmpDT.date().day(), tmpDT.time().hour(), |
1443 | tmpDT.time().minute(), tmpDT.time().second()); | 1452 | tmpDT.time().minute(), tmpDT.time().second()); |
1444 | } else { | 1453 | } else { |
1445 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", | 1454 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", |