author | zecke <zecke> | 2004-07-29 19:42:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-07-29 19:42:59 (UTC) |
commit | 52b1ae9281920cf5a40fe543112d8b00e7699ef6 (patch) (unidiff) | |
tree | 0b0a79ff9a45a66f32fe555ee662b4acc8f6eff9 /libopie2/opiepim/core | |
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
-...
-rw-r--r-- | libopie2/opiepim/core/opimevent.cpp | 36 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecurrence.cpp | 10 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimtimezone.cpp | 12 |
3 files changed, 28 insertions, 30 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 | |||
@@ -287,26 +287,28 @@ void OPimEvent::setStartDateTime( const QDateTime& dt ) | |||
287 | { | 287 | { |
288 | changeOrModify(); | 288 | changeOrModify(); |
289 | data->start = dt; | 289 | data->start = dt; |
290 | } | 290 | } |
291 | 291 | ||
292 | 292 | ||
293 | QDateTime OPimEvent::endDateTime() const | 293 | QDateTime 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 | ||
305 | QDateTime OPimEvent::endDateTimeInZone() const | 307 | QDateTime OPimEvent::endDateTimeInZone() const |
306 | { | 308 | { |
307 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 309 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
308 | if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OPimTimeZone::current().timeZone() ) return endDateTime(); | 310 | if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OPimTimeZone::current().timeZone() ) return endDateTime(); |
309 | 311 | ||
310 | OPimTimeZone zone( data->timezone ); | 312 | OPimTimeZone zone( data->timezone ); |
311 | return zone.toDateTime( data->end, OPimTimeZone::current() ); | 313 | return zone.toDateTime( data->end, OPimTimeZone::current() ); |
312 | } | 314 | } |
@@ -326,38 +328,37 @@ bool OPimEvent::isMultipleDay() const | |||
326 | 328 | ||
327 | 329 | ||
328 | bool OPimEvent::isAllDay() const | 330 | bool OPimEvent::isAllDay() const |
329 | { | 331 | { |
330 | return data->isAllDay; | 332 | return data->isAllDay; |
331 | } | 333 | } |
332 | 334 | ||
333 | 335 | ||
334 | void OPimEvent::setAllDay( bool allDay ) | 336 | void 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 | ||
342 | void OPimEvent::setTimeZone( const QString& tz ) | 343 | void 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 | ||
349 | QString OPimEvent::timeZone() const | 350 | 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; |
353 | } | 354 | } |
354 | 355 | ||
355 | 356 | ||
356 | bool OPimEvent::match( const QRegExp& re ) const | 357 | bool OPimEvent::match( const QRegExp& re ) const |
357 | { | 358 | { |
358 | if ( re.match( data->description ) != -1 ) | 359 | if ( re.match( data->description ) != -1 ) |
359 | { | 360 | { |
360 | setLastHitField( Qtopia::DatebookDescription ); | 361 | setLastHitField( Qtopia::DatebookDescription ); |
361 | return true; | 362 | return true; |
362 | } | 363 | } |
363 | if ( re.match( data->note ) != -1 ) | 364 | if ( re.match( data->note ) != -1 ) |
@@ -555,27 +556,28 @@ QMap<int, QString> OPimEvent::toMap() const | |||
555 | retMap.insert( OPimEvent::FUid, QString::number( uid() ) ); | 556 | retMap.insert( OPimEvent::FUid, QString::number( uid() ) ); |
556 | retMap.insert( OPimEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ) ); | 557 | retMap.insert( OPimEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ) ); |
557 | retMap.insert( OPimEvent::FDescription, Qtopia::escapeString( description() ) ); | 558 | retMap.insert( OPimEvent::FDescription, Qtopia::escapeString( description() ) ); |
558 | retMap.insert( OPimEvent::FLocation, Qtopia::escapeString( location() ) ); | 559 | retMap.insert( OPimEvent::FLocation, Qtopia::escapeString( location() ) ); |
559 | retMap.insert( OPimEvent::FType, isAllDay() ? "AllDay" : "" ); | 560 | retMap.insert( OPimEvent::FType, isAllDay() ? "AllDay" : "" ); |
560 | if ( notifiers().alarms().count() ){ | 561 | if ( notifiers().alarms().count() ){ |
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 | { |
576 | QArray<int> childr = children(); | 578 | QArray<int> childr = children(); |
577 | QString buf; | 579 | QString buf; |
578 | for ( uint i = 0; i < childr.count(); i++ ) | 580 | for ( uint i = 0; i < childr.count(); i++ ) |
579 | { | 581 | { |
580 | if ( i != 0 ) buf += " "; | 582 | if ( i != 0 ) buf += " "; |
581 | buf += QString::number( childr[ i ] ); | 583 | buf += QString::number( childr[ i ] ); |
@@ -627,39 +629,33 @@ void OPimEvent::fromMap( const QMap<int, QString>& map ) | |||
627 | if ( !map[ OPimEvent::FTimeZone ].isEmpty() && ( map[ OPimEvent::FTimeZone ] != "None" ) ) | 629 | if ( !map[ OPimEvent::FTimeZone ].isEmpty() && ( map[ OPimEvent::FTimeZone ] != "None" ) ) |
628 | { | 630 | { |
629 | setTimeZone( map[ OPimEvent::FTimeZone ] ); | 631 | setTimeZone( map[ OPimEvent::FTimeZone ] ); |
630 | } | 632 | } |
631 | 633 | ||
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 | ||
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 | ||
660 | int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); | 656 | int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); |
661 | if ( ( alarmTime != -1 ) ) | 657 | if ( ( alarmTime != -1 ) ) |
662 | { | 658 | { |
663 | QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 ); | 659 | QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 ); |
664 | OPimAlarm al( sound , dt ); | 660 | OPimAlarm al( sound , dt ); |
665 | notifiers().add( al ); | 661 | notifiers().add( al ); |
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 | |||
@@ -630,26 +630,26 @@ QMap<QString, OPimRecurrence::RepeatType> OPimRecurrence::rTypeValueConvertMap() | |||
630 | 630 | ||
631 | 631 | ||
632 | QMap<int, QString> OPimRecurrence::toMap() const | 632 | QMap<int, QString> OPimRecurrence::toMap() const |
633 | { | 633 | { |
634 | QMap<int, QString> retMap; | 634 | QMap<int, QString> retMap; |
635 | 635 | ||
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; |
650 | QString exceptBuf; | 650 | QString exceptBuf; |
651 | QDate date; | 651 | QDate date; |
652 | for ( it = list.begin(); it != list.end(); ++it ) { | 652 | for ( it = list.begin(); it != list.end(); ++it ) { |
653 | date = (*it); | 653 | date = (*it); |
654 | if ( it != list.begin() ) exceptBuf += " "; | 654 | if ( it != list.begin() ) exceptBuf += " "; |
655 | 655 | ||
@@ -661,29 +661,29 @@ QMap<int, QString> OPimRecurrence::toMap() const | |||
661 | return retMap; | 661 | return retMap; |
662 | } | 662 | } |
663 | 663 | ||
664 | void OPimRecurrence::fromMap( const QMap<int, QString>& map ) | 664 | void OPimRecurrence::fromMap( const QMap<int, QString>& map ) |
665 | { | 665 | { |
666 | QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap(); | 666 | QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap(); |
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 ]; |
684 | QStringList exceptList = QStringList::split( " ", exceptStr ); | 684 | QStringList exceptList = QStringList::split( " ", exceptStr ); |
685 | ... | 685 | ... |
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 | |||
@@ -39,46 +39,49 @@ | |||
39 | 39 | ||
40 | namespace Opie | 40 | namespace Opie |
41 | { | 41 | { |
42 | 42 | ||
43 | QDateTime utcTime( time_t t ) | 43 | QDateTime utcTime( time_t t ) |
44 | { | 44 | { |
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 | |||
51 | QDateTime utcTime( time_t t, const QString& zone ) | 52 | QDateTime 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 ); |
57 | ::tzset(); | 58 | ::tzset(); |
58 | 59 | ||
59 | tm* broken = ::localtime( &t ); | 60 | tm* broken = ::localtime( &t ); |
60 | ::setenv( "TZ", org, true ); | 61 | ::setenv( "TZ", org, true ); |
61 | #else | 62 | #else |
62 | #warning "Need a replacement for MacOSX!!" | 63 | #warning "Need a replacement for MacOSX!!" |
63 | 64 | ||
64 | tm* broken = ::localtime( &t ); | 65 | tm* broken = ::localtime( &t ); |
65 | #endif | 66 | #endif |
66 | 67 | ||
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 | |||
73 | time_t to_Time_t( const QDateTime& utc, const QString& str ) | 76 | time_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; |
79 | broken.tm_year = d.year() - 1900; | 82 | broken.tm_year = d.year() - 1900; |
80 | broken.tm_mon = d.month() - 1; | 83 | broken.tm_mon = d.month() - 1; |
81 | broken.tm_mday = d.day(); | 84 | broken.tm_mday = d.day(); |
82 | broken.tm_hour = t.hour(); | 85 | broken.tm_hour = t.hour(); |
83 | broken.tm_min = t.minute(); | 86 | broken.tm_min = t.minute(); |
84 | broken.tm_sec = t.second(); | 87 | broken.tm_sec = t.second(); |
@@ -142,50 +145,49 @@ QDateTime OPimTimeZone::fromUTCDateTime( time_t t ) | |||
142 | QDateTime OPimTimeZone::toDateTime( time_t t ) | 145 | QDateTime OPimTimeZone::toDateTime( time_t t ) |
143 | { | 146 | { |
144 | return utcTime( t, m_name ); | 147 | return utcTime( t, m_name ); |
145 | } | 148 | } |
146 | 149 | ||
147 | 150 | ||
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 | */ |
152 | QDateTime OPimTimeZone::toDateTime( const QDateTime& dt, const OPimTimeZone& zone ) | 155 | QDateTime 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 | ||
160 | time_t OPimTimeZone::fromDateTime( const QDateTime& time ) | 162 | time_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 | ||
166 | time_t OPimTimeZone::fromUTCDateTime( const QDateTime& time ) | 168 | 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 | } |
170 | 172 | ||
171 | 173 | ||
172 | OPimTimeZone OPimTimeZone::current() | 174 | OPimTimeZone OPimTimeZone::current() |
173 | { | 175 | { |
174 | QCString str = ::getenv( "TZ" ); | 176 | QCString str = ::getenv( "TZ" ); |
175 | OPimTimeZone zone( str ); | 177 | OPimTimeZone zone( str ); |
176 | return zone; | 178 | return zone; |
177 | } | 179 | } |
178 | 180 | ||
179 | 181 | ||
180 | OPimTimeZone OPimTimeZone::utc() | 182 | OPimTimeZone OPimTimeZone::utc() |
181 | { | 183 | { |
182 | return OPimTimeZone( "UTC" ); | 184 | return OPimTimeZone( "Europe/London" ); |
183 | } | 185 | } |
184 | 186 | ||
185 | 187 | ||
186 | QString OPimTimeZone::timeZone() const | 188 | QString OPimTimeZone::timeZone() const |
187 | { | 189 | { |
188 | return m_name; | 190 | return m_name; |
189 | } | 191 | } |
190 | 192 | ||
191 | } | 193 | } |