summaryrefslogtreecommitdiff
authorzecke <zecke>2004-07-29 19:42:59 (UTC)
committer zecke <zecke>2004-07-29 19:42:59 (UTC)
commit52b1ae9281920cf5a40fe543112d8b00e7699ef6 (patch) (unidiff)
tree0b0a79ff9a45a66f32fe555ee662b4acc8f6eff9
parentc170d1f931ae03c2ec917b7abf4bd5d0e94a3760 (diff)
downloadopie-52b1ae9281920cf5a40fe543112d8b00e7699ef6.zip
opie-52b1ae9281920cf5a40fe543112d8b00e7699ef6.tar.gz
opie-52b1ae9281920cf5a40fe543112d8b00e7699ef6.tar.bz2
-UTC -> Europe/London when referring to no timezone
-special handling for allDay Event in OPImEvent, avoid setting timezone as it is by default UTC -No timezone set by default for an Event -Recurrence is UTC (no timezone) -Provide upgrade path from DateBook as by default events were in the current timezone but didn't have the timezone attribute -unified handling of timezones, compatible with QtopiaDesktop -do less conversions -...
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp63
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.h2
-rw-r--r--libopie2/opiepim/core/opimevent.cpp36
-rw-r--r--libopie2/opiepim/core/opimrecurrence.cpp10
-rw-r--r--libopie2/opiepim/core/opimtimezone.cpp12
5 files changed, 71 insertions, 52 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
index 107c178..0f99d50 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
@@ -85,13 +85,13 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
85} 85}
86} 86}
87 87
88namespace { 88namespace {
89 time_t start, end, created, rp_end; 89 time_t start, end, created, rp_end;
90 OPimRecurrence* rec; 90 OPimRecurrence* rec;
91 OPimRecurrence* recur() { 91 static OPimRecurrence* recur() {
92 if (!rec) 92 if (!rec)
93 rec = new OPimRecurrence; 93 rec = new OPimRecurrence;
94 94
95 return rec; 95 return rec;
96 } 96 }
97 int alarmTime; 97 int alarmTime;
@@ -118,19 +118,21 @@ namespace {
118 FRecParent, 118 FRecParent,
119 FRecChildren, 119 FRecChildren,
120 FExceptions 120 FExceptions
121 }; 121 };
122 122
123 // FIXME: Use OPimEvent::toMap() here !! (eilers) 123 // FIXME: Use OPimEvent::toMap() here !! (eilers)
124 inline void save( const OPimEvent& ev, QString& buf ) { 124 static void save( const OPimEvent& ev, QString& buf ) {
125 owarn << "Saving " << ev.uid() << " " << ev.description() << "" << oendl; 125 owarn << "Saving " << ev.uid() << " " << ev.description() << "" << oendl;
126 buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; 126 buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\"";
127 if (!ev.location().isEmpty() ) 127 if (!ev.location().isEmpty() )
128 buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; 128 buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\"";
129 129
130 if (!ev.categories().isEmpty() )
130 buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; 131 buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\"";
132
131 buf += " uid=\"" + QString::number( ev.uid() ) + "\""; 133 buf += " uid=\"" + QString::number( ev.uid() ) + "\"";
132 134
133 if (ev.isAllDay() ) 135 if (ev.isAllDay() )
134 buf += " type=\"AllDay\""; // is that all ?? (eilers) 136 buf += " type=\"AllDay\""; // is that all ?? (eilers)
135 137
136 if (ev.hasNotifiers() ) { 138 if (ev.hasNotifiers() ) {
@@ -149,25 +151,32 @@ namespace {
149 151
150 /* 152 /*
151 * fscking timezones :) well, we'll first convert 153 * fscking timezones :) well, we'll first convert
152 * the QDateTime to a QDateTime in UTC time 154 * the QDateTime to a QDateTime in UTC time
153 * and then we'll create a nice time_t 155 * and then we'll create a nice time_t
154 */ 156 */
155 OPimTimeZone zone( ev.timeZone().isEmpty() ? OPimTimeZone::current() : ev.timeZone() ); 157 OPimTimeZone zone( (ev.timeZone().isEmpty()||ev.isAllDay()) ? OPimTimeZone::utc() : OPimTimeZone::current() );
156 buf += " start=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.startDateTime(), OPimTimeZone::utc() ) ) ) + "\""; 158 buf += " start=\"" + QString::number( zone.fromDateTime( ev.startDateTime())) + "\"";
157 buf += " end=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.endDateTime() , OPimTimeZone::utc() ) ) ) + "\""; 159 buf += " end=\"" + QString::number( zone.fromDateTime( ev.endDateTime() )) + "\"";
158 if (!ev.note().isEmpty() ) { 160 if (!ev.note().isEmpty() ) {
159 buf += " note=\"" + Qtopia::escapeString( ev.note() ) + "\""; 161 buf += " note=\"" + Qtopia::escapeString( ev.note() ) + "\"";
160 } 162 }
161 163
164 /*
165 * Don't save a timezone if AllDay Events
166 * as they're UTC only anyway
167 */
168 if (!ev.isAllDay() ) {
169
162 buf += " timezone=\""; 170 buf += " timezone=\"";
163 if ( ev.timeZone().isEmpty() ) 171 if ( ev.timeZone().isEmpty() )
164 buf += "None"; 172 buf += "None";
165 else 173 else
166 buf += ev.timeZone(); 174 buf += ev.timeZone();
167 buf += "\""; 175 buf += "\"";
176 }
168 177
169 if (ev.parent() != 0 ) { 178 if (ev.parent() != 0 ) {
170 buf += " recparent=\""+QString::number(ev.parent() )+"\""; 179 buf += " recparent=\""+QString::number(ev.parent() )+"\"";
171 } 180 }
172 181
173 if (ev.children().count() != 0 ) { 182 if (ev.children().count() != 0 ) {
@@ -180,13 +189,13 @@ namespace {
180 buf+= "\""; 189 buf+= "\"";
181 } 190 }
182 191
183 // skip custom writing 192 // skip custom writing
184 } 193 }
185 194
186 inline bool forAll( const QMap<int, OPimEvent>& list, QFile& file ) { 195 static bool saveEachEvent( const QMap<int, OPimEvent>& list, QFile& file ) {
187 QMap<int, OPimEvent>::ConstIterator it; 196 QMap<int, OPimEvent>::ConstIterator it;
188 QString buf; 197 QString buf;
189 QCString str; 198 QCString str;
190 int total_written; 199 int total_written;
191 for ( it = list.begin(); it != list.end(); ++it ) { 200 for ( it = list.begin(); it != list.end(); ++it ) {
192 buf = "<event"; 201 buf = "<event";
@@ -235,18 +244,18 @@ bool ODateBookAccessBackend_XML::save() {
235 if ( total_written != int(str.length() ) ) { 244 if ( total_written != int(str.length() ) ) {
236 f.close(); 245 f.close();
237 QFile::remove( strFileNew ); 246 QFile::remove( strFileNew );
238 return false; 247 return false;
239 } 248 }
240 249
241 if (!forAll( m_raw, f ) ) { 250 if (!saveEachEvent( m_raw, f ) ) {
242 f.close(); 251 f.close();
243 QFile::remove( strFileNew ); 252 QFile::remove( strFileNew );
244 return false; 253 return false;
245 } 254 }
246 if (!forAll( m_rep, f ) ) { 255 if (!saveEachEvent( m_rep, f ) ) {
247 f.close(); 256 f.close();
248 QFile::remove( strFileNew ); 257 QFile::remove( strFileNew );
249 return false; 258 return false;
250 } 259 }
251 260
252 buf = "</events>\n</DATEBOOK>\n"; 261 buf = "</events>\n</DATEBOOK>\n";
@@ -403,12 +412,16 @@ bool ODateBookAccessBackend_XML::loadFile() {
403 dict.insert( "created", new int(FCreated) ); // Shouldn't this be FRCreated ?? 412 dict.insert( "created", new int(FCreated) ); // Shouldn't this be FRCreated ??
404 dict.insert( "recparent", new int(FRecParent) ); 413 dict.insert( "recparent", new int(FRecParent) );
405 dict.insert( "recchildren", new int(FRecChildren) ); 414 dict.insert( "recchildren", new int(FRecChildren) );
406 dict.insert( "exceptions", new int(FExceptions) ); 415 dict.insert( "exceptions", new int(FExceptions) );
407 dict.insert( "timezone", new int(FTimeZone) ); 416 dict.insert( "timezone", new int(FTimeZone) );
408 417
418
419 // initialiaze db hack
420 m_noTimeZone = true;
421
409 char* dt = (char*)map_addr; 422 char* dt = (char*)map_addr;
410 int len = attribute.st_size; 423 int len = attribute.st_size;
411 int i = 0; 424 int i = 0;
412 char* point; 425 char* point;
413 const char* collectionString = "<event "; 426 const char* collectionString = "<event ";
414 int strLen = ::strlen(collectionString); 427 int strLen = ::strlen(collectionString);
@@ -476,43 +489,49 @@ bool ODateBookAccessBackend_XML::loadFile() {
476 setField( ev, *find, str ); 489 setField( ev, *find, str );
477 } 490 }
478 } 491 }
479 /* time to finalize */ 492 /* time to finalize */
480 finalizeRecord( ev ); 493 finalizeRecord( ev );
481 delete rec; 494 delete rec;
495 m_noTimeZone = true;
482 } 496 }
483 ::munmap(map_addr, attribute.st_size ); 497 ::munmap(map_addr, attribute.st_size );
484 m_changed = false; // changed during add 498 m_changed = false; // changed during add
485 499
486 return true; 500 return true;
487} 501}
488 502
489// FIXME: Use OPimEvent::fromMap() which makes this obsolete.. (eilers) 503// FIXME: Use OPimEvent::fromMap() which makes this obsolete.. (eilers)
490void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) { 504void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) {
505
506 /*
507 * quirk to import datebook files. They normally don't have a
508 * timeZone attribute and we treat this as to use OPimTimeZone::current()
509 */
510 if (m_noTimeZone )
511 ev.setTimeZone( OPimTimeZone::current().timeZone() );
512
513
514
491 /* AllDay is alway in UTC */ 515 /* AllDay is alway in UTC */
492 if ( ev.isAllDay() ) { 516 if ( ev.isAllDay() ) {
493 OPimTimeZone utc = OPimTimeZone::utc(); 517 OPimTimeZone utc = OPimTimeZone::utc();
494 ev.setStartDateTime( utc.fromUTCDateTime( start ) ); 518 ev.setStartDateTime( utc.toDateTime( start ) );
495 ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); 519 ev.setEndDateTime ( utc.toDateTime( end ) );
496 ev.setTimeZone( "UTC"); // make sure it is really utc
497 }else { 520 }else {
498 /* to current date time */ 521 /* to current date time */
499 // owarn << " Start is " << start << "" << oendl; 522 OPimTimeZone to_zone( ev.timeZone().isEmpty() ? OPimTimeZone::utc() : OPimTimeZone::current() );
500 OPimTimeZone zone( ev.timeZone().isEmpty() ? OPimTimeZone::current() : ev.timeZone() );
501 QDateTime date = zone.toDateTime( start );
502 owarn << " Start is " << date.toString() << "" << oendl;
503 ev.setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) );
504 523
505 date = zone.toDateTime( end ); 524 ev.setStartDateTime(to_zone.toDateTime( start));
506 ev.setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) ); 525 ev.setEndDateTime (to_zone.toDateTime( end));
507 } 526 }
508 if ( rec && rec->doesRecur() ) { 527 if ( rec && rec->doesRecur() ) {
509 OPimTimeZone utc = OPimTimeZone::utc(); 528 OPimTimeZone utc = OPimTimeZone::utc();
510 OPimRecurrence recu( *rec ); // call copy c'tor; 529 OPimRecurrence recu( *rec ); // call copy c'tor;
511 recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); 530 recu.setEndDate ( utc.toDateTime( rp_end ).date() );
512 recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); 531 recu.setCreatedDateTime( utc.toDateTime( created ) );
513 recu.setStart( ev.startDateTime().date() ); 532 recu.setStart( ev.startDateTime().date() );
514 ev.setRecurrence( recu ); 533 ev.setRecurrence( recu );
515 } 534 }
516 535
517 if (alarmTime != -1 ) { 536 if (alarmTime != -1 ) {
518 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); 537 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 );
@@ -520,13 +539,13 @@ void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) {
520 ev.notifiers().add( al ); 539 ev.notifiers().add( al );
521 } 540 }
522 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { 541 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) {
523 owarn << "already contains assign uid" << oendl; 542 owarn << "already contains assign uid" << oendl;
524 ev.setUid( 1 ); 543 ev.setUid( 1 );
525 } 544 }
526 owarn << "addind " << ev.uid() << " " << ev.description() << "" << oendl; 545
527 if ( ev.hasRecurrence() ) 546 if ( ev.hasRecurrence() )
528 m_rep.insert( ev.uid(), ev ); 547 m_rep.insert( ev.uid(), ev );
529 else 548 else
530 m_raw.insert( ev.uid(), ev ); 549 m_raw.insert( ev.uid(), ev );
531 550
532} 551}
@@ -545,13 +564,12 @@ void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString&
545 case FUid: 564 case FUid:
546 e.setUid( value.toInt() ); 565 e.setUid( value.toInt() );
547 break; 566 break;
548 case FType: 567 case FType:
549 if ( value == "AllDay" ) { 568 if ( value == "AllDay" ) {
550 e.setAllDay( true ); 569 e.setAllDay( true );
551 e.setTimeZone( "UTC" );
552 } 570 }
553 break; 571 break;
554 case FAlarm: 572 case FAlarm:
555 alarmTime = value.toInt(); 573 alarmTime = value.toInt();
556 break; 574 break;
557 case FSound: 575 case FSound:
@@ -619,12 +637,13 @@ void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString&
619 owarn << "adding exception " << date.toString() << "" << oendl; 637 owarn << "adding exception " << date.toString() << "" << oendl;
620 recur()->exceptions().append( date ); 638 recur()->exceptions().append( date );
621 } 639 }
622 } 640 }
623 break; 641 break;
624 case FTimeZone: 642 case FTimeZone:
643 m_noTimeZone = false;
625 if ( value != "None" ) 644 if ( value != "None" )
626 e.setTimeZone( value ); 645 e.setTimeZone( value );
627 break; 646 break;
628 default: 647 default:
629 break; 648 break;
630 } 649 }
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
index 6823ce6..af5b114 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
@@ -65,12 +65,14 @@ public:
65 65
66 OPimEvent::ValueList directNonRepeats(); 66 OPimEvent::ValueList directNonRepeats();
67 OPimEvent::ValueList directRawRepeats(); 67 OPimEvent::ValueList directRawRepeats();
68 68
69private: 69private:
70 bool m_changed :1 ; 70 bool m_changed :1 ;
71 bool m_noTimeZone : 1;
72
71 bool loadFile(); 73 bool loadFile();
72 inline void finalizeRecord( OPimEvent& ev ); 74 inline void finalizeRecord( OPimEvent& ev );
73 inline void setField( OPimEvent&, int field, const QString& val ); 75 inline void setField( OPimEvent&, int field, const QString& val );
74 QString m_name; 76 QString m_name;
75 QMap<int, OPimEvent> m_raw; 77 QMap<int, OPimEvent> m_raw;
76 QMap<int, OPimEvent> m_rep; 78 QMap<int, OPimEvent> m_rep;
diff --git a/libopie2/opiepim/core/opimevent.cpp b/libopie2/opiepim/core/opimevent.cpp
index 8752fce..739cb6f 100644
--- a/libopie2/opiepim/core/opimevent.cpp
+++ b/libopie2/opiepim/core/opimevent.cpp
@@ -293,14 +293,16 @@ void OPimEvent::setStartDateTime( const QDateTime& dt )
293QDateTime OPimEvent::endDateTime() const 293QDateTime OPimEvent::endDateTime() const
294{ 294{
295 /* 295 /*
296 * if all Day event the end time needs 296 * if all Day event the end time needs
297 * to be on the same day as the start 297 * to be on the same day as the start
298 */ 298 */
299 if ( data->isAllDay ) 299 if ( data->isAllDay ) {
300 return QDateTime( data->start.date(), QTime( 23, 59, 59 ) ); 300 QDate end = data->end.isValid() ? data->end.date() : data->start.date() ;
301 return QDateTime( end, QTime( 23, 59, 59 ) );
302 }
301 return data->end; 303 return data->end;
302} 304}
303 305
304 306
305QDateTime OPimEvent::endDateTimeInZone() const 307QDateTime OPimEvent::endDateTimeInZone() const
306{ 308{
@@ -332,26 +334,25 @@ bool OPimEvent::isAllDay() const
332 334
333 335
334void OPimEvent::setAllDay( bool allDay ) 336void OPimEvent::setAllDay( bool allDay )
335{ 337{
336 changeOrModify(); 338 changeOrModify();
337 data->isAllDay = allDay; 339 data->isAllDay = allDay;
338 if ( allDay ) data->timezone = "UTC";
339} 340}
340 341
341 342
342void OPimEvent::setTimeZone( const QString& tz ) 343void OPimEvent::setTimeZone( const QString& tz )
343{ 344{
344 changeOrModify(); 345 changeOrModify();
345 data->timezone = tz; 346 data->timezone = tz;
346} 347}
347 348
348 349
349QString OPimEvent::timeZone() const 350QString OPimEvent::timeZone() const
350{ 351{
351 if ( data->isAllDay ) return QString::fromLatin1( "UTC" ); 352 if ( data->isAllDay ) return QString::fromLatin1( "Europe/London" );
352 return data->timezone; 353 return data->timezone;
353} 354}
354 355
355 356
356bool OPimEvent::match( const QRegExp& re ) const 357bool OPimEvent::match( const QRegExp& re ) const
357{ 358{
@@ -561,15 +562,16 @@ QMap<int, QString> OPimEvent::toMap() const
561 // Currently we just support one alarm.. (eilers) 562 // Currently we just support one alarm.. (eilers)
562 OPimAlarm alarm = notifiers().alarms() [ 0 ]; 563 OPimAlarm alarm = notifiers().alarms() [ 0 ];
563 retMap.insert( OPimEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); 564 retMap.insert( OPimEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) );
564 retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" ); 565 retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" );
565 } 566 }
566 567
567 OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); 568 /* either use UTC timeZone or current() if there is was a timezone set */
568 retMap.insert( OPimEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OPimTimeZone::utc() ) ) ) ); 569 OPimTimeZone zone( (timeZone().isEmpty()||isAllDay()) ? OPimTimeZone::utc() : OPimTimeZone::current() );
569 retMap.insert( OPimEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OPimTimeZone::utc() ) ) ) ); 570 retMap.insert( OPimEvent::FStart, QString::number( zone.fromDateTime( startDateTime())));
571 retMap.insert( OPimEvent::FEnd, QString::number( zone.fromDateTime( endDateTime() )));
570 retMap.insert( OPimEvent::FNote, Qtopia::escapeString( note() ) ); 572 retMap.insert( OPimEvent::FNote, Qtopia::escapeString( note() ) );
571 retMap.insert( OPimEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); 573 retMap.insert( OPimEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() );
572 if ( parent() ) 574 if ( parent() )
573 retMap.insert( OPimEvent::FRecParent, QString::number( parent() ) ); 575 retMap.insert( OPimEvent::FRecParent, QString::number( parent() ) );
574 if ( children().count() ) 576 if ( children().count() )
575 { 577 {
@@ -633,27 +635,21 @@ void OPimEvent::fromMap( const QMap<int, QString>& map )
633 time_t end = ( time_t ) map[ OPimEvent::FEnd ].toLong(); 635 time_t end = ( time_t ) map[ OPimEvent::FEnd ].toLong();
634 636
635 /* AllDay is always in UTC */ 637 /* AllDay is always in UTC */
636 if ( isAllDay() ) 638 if ( isAllDay() )
637 { 639 {
638 OPimTimeZone utc = OPimTimeZone::utc(); 640 OPimTimeZone utc = OPimTimeZone::utc();
639 setStartDateTime( utc.fromUTCDateTime( start ) ); 641 setStartDateTime(utc.toDateTime( start ) );
640 setEndDateTime ( utc.fromUTCDateTime( end ) ); 642 setEndDateTime ( utc.toDateTime( end ) );
641 setTimeZone( "UTC" ); // make sure it is really utc
642 } 643 }
643 else 644 else {
644 {
645 /* to current date time */ 645 /* to current date time */
646 // owarn << " Start is " << start << "" << oendl; 646 OPimTimeZone to_zone( ev.timeZone().isEmpty() ? OPimTimeZone::utc() : OPimTimeZone::current() );
647 OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); 647
648 QDateTime date = zone.toDateTime( start ); 648 ev.setStartDateTime(to_zone.toDateTime( start));
649 owarn << " Start is " << date.toString() << "" << oendl; 649 ev.setEndDateTime (to_zone.toDateTime( end));
650 setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) );
651
652 date = zone.toDateTime( end );
653 setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) );
654 } 650 }
655 651
656 int alarmTime = -1; 652 int alarmTime = -1;
657 if ( !map[ OPimEvent::FAlarm ].isEmpty() ) 653 if ( !map[ OPimEvent::FAlarm ].isEmpty() )
658 alarmTime = map[ OPimEvent::FAlarm ].toInt(); 654 alarmTime = map[ OPimEvent::FAlarm ].toInt();
659 655
diff --git a/libopie2/opiepim/core/opimrecurrence.cpp b/libopie2/opiepim/core/opimrecurrence.cpp
index 4b1d886..c3ae350 100644
--- a/libopie2/opiepim/core/opimrecurrence.cpp
+++ b/libopie2/opiepim/core/opimrecurrence.cpp
@@ -636,14 +636,14 @@ QMap<int, QString> OPimRecurrence::toMap() const
636 retMap.insert( OPimRecurrence::RType, rTypeString() ); 636 retMap.insert( OPimRecurrence::RType, rTypeString() );
637 retMap.insert( OPimRecurrence::RWeekdays, QString::number( static_cast<int>( data->days ) ) ); 637 retMap.insert( OPimRecurrence::RWeekdays, QString::number( static_cast<int>( data->days ) ) );
638 retMap.insert( OPimRecurrence::RPosition, QString::number(data->pos ) ); 638 retMap.insert( OPimRecurrence::RPosition, QString::number(data->pos ) );
639 retMap.insert( OPimRecurrence::RFreq, QString::number( data->freq ) ); 639 retMap.insert( OPimRecurrence::RFreq, QString::number( data->freq ) );
640 retMap.insert( OPimRecurrence::RHasEndDate, QString::number( static_cast<int>( data->hasEnd ) ) ); 640 retMap.insert( OPimRecurrence::RHasEndDate, QString::number( static_cast<int>( data->hasEnd ) ) );
641 if( data -> hasEnd ) 641 if( data -> hasEnd )
642 retMap.insert( OPimRecurrence::EndDate, QString::number( OPimTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) ) ); 642 retMap.insert( OPimRecurrence::EndDate, QString::number( OPimTimeZone::current().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) ) );
643 retMap.insert( OPimRecurrence::Created, QString::number( OPimTimeZone::utc().fromUTCDateTime( data->create ) ) ); 643 retMap.insert( OPimRecurrence::Created, QString::number( OPimTimeZone::current().fromUTCDateTime( data->create ) ) );
644 644
645 if ( data->list.isEmpty() ) return retMap; 645 if ( data->list.isEmpty() ) return retMap;
646 646
647 // save exceptions list here!! 647 // save exceptions list here!!
648 ExceptionList::ConstIterator it; 648 ExceptionList::ConstIterator it;
649 ExceptionList list = data->list; 649 ExceptionList list = data->list;
@@ -667,17 +667,17 @@ void OPimRecurrence::fromMap( const QMap<int, QString>& map )
667 667
668 data -> type = repTypeMap[ map [OPimRecurrence::RType] ]; 668 data -> type = repTypeMap[ map [OPimRecurrence::RType] ];
669 data -> days = (char) map[ OPimRecurrence::RWeekdays ].toInt(); 669 data -> days = (char) map[ OPimRecurrence::RWeekdays ].toInt();
670 data -> pos = map[ OPimRecurrence::RPosition ].toInt(); 670 data -> pos = map[ OPimRecurrence::RPosition ].toInt();
671 data -> freq = map[ OPimRecurrence::RFreq ].toInt(); 671 data -> freq = map[ OPimRecurrence::RFreq ].toInt();
672 data -> hasEnd= map[ OPimRecurrence::RHasEndDate ].toInt() ? true : false; 672 data -> hasEnd= map[ OPimRecurrence::RHasEndDate ].toInt() ? true : false;
673 OPimTimeZone utc = OPimTimeZone::utc(); 673 OPimTimeZone cur = OPimTimeZone::current();
674 if ( data -> hasEnd ){ 674 if ( data -> hasEnd ){
675 data -> end = utc.fromUTCDateTime( (time_t) map[ OPimRecurrence::EndDate ].toLong() ).date(); 675 data -> end = cur.fromUTCDateTime( (time_t) map[ OPimRecurrence::EndDate ].toLong() ).date();
676 } 676 }
677 data -> create = utc.fromUTCDateTime( (time_t) map[ OPimRecurrence::Created ].toLong() ).date(); 677 data -> create = cur.fromUTCDateTime( (time_t) map[ OPimRecurrence::Created ].toLong() ).date();
678 678
679#if 0 679#if 0
680 // FIXME: Exceptions currently not supported... 680 // FIXME: Exceptions currently not supported...
681 // Convert the list of exceptions from QString into ExceptionList 681 // Convert the list of exceptions from QString into ExceptionList
682 data -> list.clear(); 682 data -> list.clear();
683 QString exceptStr = map[ OPimRecurrence::Exceptions ]; 683 QString exceptStr = map[ OPimRecurrence::Exceptions ];
diff --git a/libopie2/opiepim/core/opimtimezone.cpp b/libopie2/opiepim/core/opimtimezone.cpp
index fefceb5..5b32b1f 100644
--- a/libopie2/opiepim/core/opimtimezone.cpp
+++ b/libopie2/opiepim/core/opimtimezone.cpp
@@ -45,12 +45,13 @@ QDateTime utcTime( time_t t )
45 tm * broken = ::gmtime( &t ); 45 tm * broken = ::gmtime( &t );
46 QDateTime ret; 46 QDateTime ret;
47 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) ); 47 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) );
48 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); 48 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) );
49 return ret; 49 return ret;
50} 50}
51
51QDateTime utcTime( time_t t, const QString& zone ) 52QDateTime utcTime( time_t t, const QString& zone )
52{ 53{
53 QCString org = ::getenv( "TZ" ); 54 QCString org = ::getenv( "TZ" );
54#ifndef Q_OS_MACX // Following line causes bus errors on Mac 55#ifndef Q_OS_MACX // Following line causes bus errors on Mac
55 56
56 ::setenv( "TZ", zone.latin1(), true ); 57 ::setenv( "TZ", zone.latin1(), true );
@@ -67,12 +68,14 @@ QDateTime utcTime( time_t t, const QString& zone )
67 QDateTime ret; 68 QDateTime ret;
68 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) ); 69 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) );
69 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); 70 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) );
70 71
71 return ret; 72 return ret;
72} 73}
74
75
73time_t to_Time_t( const QDateTime& utc, const QString& str ) 76time_t to_Time_t( const QDateTime& utc, const QString& str )
74{ 77{
75 QDate d = utc.date(); 78 QDate d = utc.date();
76 QTime t = utc.time(); 79 QTime t = utc.time();
77 80
78 tm broken; 81 tm broken;
@@ -148,27 +151,26 @@ QDateTime OPimTimeZone::toDateTime( time_t t )
148/* 151/*
149 * convert dt to utc using zone.m_name 152 * convert dt to utc using zone.m_name
150 * convert utc -> timeZoneDT using this->m_name 153 * convert utc -> timeZoneDT using this->m_name
151 */ 154 */
152QDateTime OPimTimeZone::toDateTime( const QDateTime& dt, const OPimTimeZone& zone ) 155QDateTime OPimTimeZone::toDateTime( const QDateTime& dt, const OPimTimeZone& zone )
153{ 156{
154 time_t utc = to_Time_t( dt, zone.m_name ); 157 time_t utc = to_Time_t( dt, m_name );
155 owarn << "" << utc << " " << zone.m_name << "" << oendl; 158 return utcTime( utc, zone.m_name );
156 return utcTime( utc, m_name );
157} 159}
158 160
159 161
160time_t OPimTimeZone::fromDateTime( const QDateTime& time ) 162time_t OPimTimeZone::fromDateTime( const QDateTime& time )
161{ 163{
162 return to_Time_t( time, m_name ); 164 return to_Time_t( time, m_name );
163} 165}
164 166
165 167
166time_t OPimTimeZone::fromUTCDateTime( const QDateTime& time ) 168time_t OPimTimeZone::fromUTCDateTime( const QDateTime& time )
167{ 169{
168 return to_Time_t( time, "UTC" ); 170 return to_Time_t( time, "Europe/London" );
169} 171}
170 172
171 173
172OPimTimeZone OPimTimeZone::current() 174OPimTimeZone OPimTimeZone::current()
173{ 175{
174 QCString str = ::getenv( "TZ" ); 176 QCString str = ::getenv( "TZ" );
@@ -176,13 +178,13 @@ OPimTimeZone OPimTimeZone::current()
176 return zone; 178 return zone;
177} 179}
178 180
179 181
180OPimTimeZone OPimTimeZone::utc() 182OPimTimeZone OPimTimeZone::utc()
181{ 183{
182 return OPimTimeZone( "UTC" ); 184 return OPimTimeZone( "Europe/London" );
183} 185}
184 186
185 187
186QString OPimTimeZone::timeZone() const 188QString OPimTimeZone::timeZone() const
187{ 189{
188 return m_name; 190 return m_name;