author | zecke <zecke> | 2004-07-29 19:42:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-07-29 19:42:59 (UTC) |
commit | 52b1ae9281920cf5a40fe543112d8b00e7699ef6 (patch) (side-by-side diff) | |
tree | 0b0a79ff9a45a66f32fe555ee662b4acc8f6eff9 /libopie2/opiepim/core/opimevent.cpp | |
parent | c170d1f931ae03c2ec917b7abf4bd5d0e94a3760 (diff) | |
download | opie-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 (limited to 'libopie2/opiepim/core/opimevent.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimevent.cpp | 38 |
1 files changed, 17 insertions, 21 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 @@ -296,8 +296,10 @@ QDateTime OPimEvent::endDateTime() const * if all Day event the end time needs * to be on the same day as the start */ - if ( data->isAllDay ) - return QDateTime( data->start.date(), QTime( 23, 59, 59 ) ); + if ( data->isAllDay ) { + QDate end = data->end.isValid() ? data->end.date() : data->start.date() ; + return QDateTime( end, QTime( 23, 59, 59 ) ); + } return data->end; } @@ -335,7 +337,6 @@ void OPimEvent::setAllDay( bool allDay ) { changeOrModify(); data->isAllDay = allDay; - if ( allDay ) data->timezone = "UTC"; } @@ -348,7 +349,7 @@ void OPimEvent::setTimeZone( const QString& tz ) QString OPimEvent::timeZone() const { - if ( data->isAllDay ) return QString::fromLatin1( "UTC" ); + if ( data->isAllDay ) return QString::fromLatin1( "Europe/London" ); return data->timezone; } @@ -564,9 +565,10 @@ QMap<int, QString> OPimEvent::toMap() const retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" ); } - OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); - retMap.insert( OPimEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OPimTimeZone::utc() ) ) ) ); - retMap.insert( OPimEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OPimTimeZone::utc() ) ) ) ); + /* either use UTC timeZone or current() if there is was a timezone set */ + OPimTimeZone zone( (timeZone().isEmpty()||isAllDay()) ? OPimTimeZone::utc() : OPimTimeZone::current() ); + retMap.insert( OPimEvent::FStart, QString::number( zone.fromDateTime( startDateTime()))); + retMap.insert( OPimEvent::FEnd, QString::number( zone.fromDateTime( endDateTime() ))); retMap.insert( OPimEvent::FNote, Qtopia::escapeString( note() ) ); retMap.insert( OPimEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); if ( parent() ) @@ -630,27 +632,21 @@ void OPimEvent::fromMap( const QMap<int, QString>& map ) } time_t start = ( time_t ) map[ OPimEvent::FStart ].toLong(); - time_t end = ( time_t ) map[ OPimEvent::FEnd ].toLong(); + time_t end = ( time_t ) map[ OPimEvent::FEnd ].toLong(); /* AllDay is always in UTC */ if ( isAllDay() ) { OPimTimeZone utc = OPimTimeZone::utc(); - setStartDateTime( utc.fromUTCDateTime( start ) ); - setEndDateTime ( utc.fromUTCDateTime( end ) ); - setTimeZone( "UTC" ); // make sure it is really utc + setStartDateTime(utc.toDateTime( start ) ); + setEndDateTime ( utc.toDateTime( end ) ); } - else - { + else { /* to current date time */ - // owarn << " Start is " << start << "" << oendl; - OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); - QDateTime date = zone.toDateTime( start ); - owarn << " Start is " << date.toString() << "" << oendl; - setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) ); - - date = zone.toDateTime( end ); - setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) ); + OPimTimeZone to_zone( ev.timeZone().isEmpty() ? OPimTimeZone::utc() : OPimTimeZone::current() ); + + ev.setStartDateTime(to_zone.toDateTime( start)); + ev.setEndDateTime (to_zone.toDateTime( end)); } int alarmTime = -1; |