summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core
Unidiff
Diffstat (limited to 'libopie2/opiepim/core') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimevent.cpp38
-rw-r--r--libopie2/opiepim/core/opimrecurrence.cpp22
-rw-r--r--libopie2/opiepim/core/opimtimezone.cpp12
3 files changed, 35 insertions, 37 deletions
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
@@ -298,4 +298,6 @@ QDateTime OPimEvent::endDateTime() const
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;
@@ -337,3 +339,2 @@ void OPimEvent::setAllDay( bool allDay )
337 data->isAllDay = allDay; 339 data->isAllDay = allDay;
338 if ( allDay ) data->timezone = "UTC";
339} 340}
@@ -350,3 +351,3 @@ QString 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;
@@ -566,5 +567,6 @@ QMap<int, QString> OPimEvent::toMap() const
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() ) );
@@ -632,3 +634,3 @@ void OPimEvent::fromMap( const QMap<int, QString>& map )
632 time_t start = ( time_t ) map[ OPimEvent::FStart ].toLong(); 634 time_t start = ( time_t ) map[ OPimEvent::FStart ].toLong();
633 time_t end = ( time_t ) map[ OPimEvent::FEnd ].toLong(); 635 time_t end = ( time_t ) map[ OPimEvent::FEnd ].toLong();
634 636
@@ -638,17 +640,11 @@ void OPimEvent::fromMap( const QMap<int, QString>& map )
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 }
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
@@ -634,3 +634,3 @@ QMap<int, QString> OPimRecurrence::toMap() const
634 QMap<int, QString> retMap; 634 QMap<int, QString> retMap;
635 635
636 retMap.insert( OPimRecurrence::RType, rTypeString() ); 636 retMap.insert( OPimRecurrence::RType, rTypeString() );
@@ -641,5 +641,5 @@ QMap<int, QString> OPimRecurrence::toMap() const
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;
@@ -654,3 +654,3 @@ QMap<int, QString> OPimRecurrence::toMap() const
654 if ( it != list.begin() ) exceptBuf += " "; 654 if ( it != list.begin() ) exceptBuf += " ";
655 655
656 exceptBuf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() ); 656 exceptBuf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() );
@@ -665,3 +665,3 @@ void OPimRecurrence::fromMap( const QMap<int, QString>& map )
665{ 665{
666 QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap(); 666 QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap();
667 667
@@ -672,7 +672,7 @@ void OPimRecurrence::fromMap( const QMap<int, QString>& map )
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
@@ -686,4 +686,4 @@ void OPimRecurrence::fromMap( const QMap<int, QString>& map )
686#endif 686#endif
687 687
688 688
689} 689}
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
@@ -50,2 +50,3 @@ QDateTime utcTime( time_t t )
50} 50}
51
51QDateTime utcTime( time_t t, const QString& zone ) 52QDateTime utcTime( time_t t, const QString& zone )
@@ -72,2 +73,4 @@ QDateTime utcTime( time_t t, const QString& zone )
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 )
@@ -153,5 +156,4 @@ QDateTime OPimTimeZone::toDateTime( const QDateTime& dt, const OPimTimeZone& zon
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}
@@ -167,3 +169,3 @@ time_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}
@@ -181,3 +183,3 @@ OPimTimeZone OPimTimeZone::utc()
181{ 183{
182 return OPimTimeZone( "UTC" ); 184 return OPimTimeZone( "Europe/London" );
183} 185}