author | eilers <eilers> | 2002-12-07 13:26:22 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-12-07 13:26:22 (UTC) |
commit | 1e0c4ae8e82863179199b0437a6d9cca6b661a7e (patch) (side-by-side diff) | |
tree | 8a452f8747290d638787ee47a3a8bf8147db0786 | |
parent | ad2a10877ae6e50b1a765a9b7cff14494c65e588 (diff) | |
download | opie-1e0c4ae8e82863179199b0437a6d9cca6b661a7e.zip opie-1e0c4ae8e82863179199b0437a6d9cca6b661a7e.tar.gz opie-1e0c4ae8e82863179199b0437a6d9cca6b661a7e.tar.bz2 |
Fixing bug in storing anniversary..
-rw-r--r-- | libopie/pim/ocontactaccessbackend_vcard.cpp | 37 | ||||
-rw-r--r-- | libopie/pim/ocontactaccessbackend_vcard.h | 4 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp | 37 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_vcard.h | 4 |
4 files changed, 56 insertions, 26 deletions
diff --git a/libopie/pim/ocontactaccessbackend_vcard.cpp b/libopie/pim/ocontactaccessbackend_vcard.cpp index 09ae37b..ca9e410 100644 --- a/libopie/pim/ocontactaccessbackend_vcard.cpp +++ b/libopie/pim/ocontactaccessbackend_vcard.cpp @@ -19,2 +19,5 @@ * $Log$ + * Revision 1.5 2002/12/07 13:26:22 eilers + * Fixing bug in storing anniversary.. + * * Revision 1.4 2002/11/13 14:14:51 eilers @@ -385,3 +388,3 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) else if ( name == "X-Qtopia-Anniversary" ) { - c.setAnniversary( TimeConversion::fromString( value ) ); + c.setAnniversary( convVCardDateToDate( value ) ); } @@ -496,13 +499,4 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) if ( c.birthday().isValid() ){ - QString birthd_rfc2425 = QString("%1-%2-%3") - .arg( c.birthday().year() ) - .arg( c.birthday().month(), 2 ) - .arg( c.birthday().day(), 2 ); - // Now replace spaces with "0"... - int pos = 0; - while ( ( pos = birthd_rfc2425.find (' ') ) > 0 ) - birthd_rfc2425.replace( pos, 1, "0" ); - - qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); - safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); + qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); + safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); } @@ -523,3 +517,6 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); - safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); + if ( c.anniversary().isValid() ){ + qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); + safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); + } safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); @@ -530,2 +527,16 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) +QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const +{ + QString str_rfc2425 = QString("%1-%2-%3") + .arg( d.year() ) + .arg( d.month(), 2 ) + .arg( d.day(), 2 ); + // Now replace spaces with "0"... + int pos = 0; + while ( ( pos = str_rfc2425.find (' ') ) > 0 ) + str_rfc2425.replace( pos, 1, "0" ); + + return str_rfc2425; +} + QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) diff --git a/libopie/pim/ocontactaccessbackend_vcard.h b/libopie/pim/ocontactaccessbackend_vcard.h index 4437756..236da00 100644 --- a/libopie/pim/ocontactaccessbackend_vcard.h +++ b/libopie/pim/ocontactaccessbackend_vcard.h @@ -19,2 +19,5 @@ * $Log$ + * Revision 1.4 2002/12/07 13:26:22 eilers + * Fixing bug in storing anniversary.. + * * Revision 1.3 2002/11/13 14:14:51 eilers @@ -64,2 +67,3 @@ private: VObject* createVObject( const OContact& c ); + QString convDateToVCardDate( const QDate& c ) const; QDate convVCardDateToDate( const QString& datestr ); diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp index 09ae37b..ca9e410 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp @@ -19,2 +19,5 @@ * $Log$ + * Revision 1.5 2002/12/07 13:26:22 eilers + * Fixing bug in storing anniversary.. + * * Revision 1.4 2002/11/13 14:14:51 eilers @@ -385,3 +388,3 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) else if ( name == "X-Qtopia-Anniversary" ) { - c.setAnniversary( TimeConversion::fromString( value ) ); + c.setAnniversary( convVCardDateToDate( value ) ); } @@ -496,13 +499,4 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) if ( c.birthday().isValid() ){ - QString birthd_rfc2425 = QString("%1-%2-%3") - .arg( c.birthday().year() ) - .arg( c.birthday().month(), 2 ) - .arg( c.birthday().day(), 2 ); - // Now replace spaces with "0"... - int pos = 0; - while ( ( pos = birthd_rfc2425.find (' ') ) > 0 ) - birthd_rfc2425.replace( pos, 1, "0" ); - - qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); - safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); + qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); + safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); } @@ -523,3 +517,6 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); - safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); + if ( c.anniversary().isValid() ){ + qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); + safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); + } safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); @@ -530,2 +527,16 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) +QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const +{ + QString str_rfc2425 = QString("%1-%2-%3") + .arg( d.year() ) + .arg( d.month(), 2 ) + .arg( d.day(), 2 ); + // Now replace spaces with "0"... + int pos = 0; + while ( ( pos = str_rfc2425.find (' ') ) > 0 ) + str_rfc2425.replace( pos, 1, "0" ); + + return str_rfc2425; +} + QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h index 4437756..236da00 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h @@ -19,2 +19,5 @@ * $Log$ + * Revision 1.4 2002/12/07 13:26:22 eilers + * Fixing bug in storing anniversary.. + * * Revision 1.3 2002/11/13 14:14:51 eilers @@ -64,2 +67,3 @@ private: VObject* createVObject( const OContact& c ); + QString convDateToVCardDate( const QDate& c ) const; QDate convVCardDateToDate( const QString& datestr ); |