[Kde-pim] Review Request: vCard export: export birthday field as date only

Allen Winter winter at kde.org
Sat Jan 28 14:12:08 GMT 2012


On Thursday 26 January 2012 7:43:17 AM Jonathan Marten wrote:
> 
> OK, found the fundamental problem.  ContactEditorWidget::storeContact() stores the entered birthday by doing:
> 
>   contact.setBirthday( QDateTime( d->mBirthdateWidget->date(), QTime(), contact.birthday().timeSpec() ) );
> 
> obviously intending to store it with an invalid time.  But this won't work, cf. the QDateTime documentation (not sure whether this has always been the case or is new for 4.8):
> 
>   QDateTime::QDateTime ( const QDate & date, const QTime & time, Qt::TimeSpec spec = Qt::LocalTime )
> 
>   Constructs a datetime with the given date and time, using the time specification defined by spec.
>   If date is valid and time is not, the time will be set to midnight.
> 
> So the birthday is stored with a valid time of midnight, and this persists all through the Akonadi storage and export.
> 
> Changing the above code to do:
> 
>   QDateTime birthday = QDateTime( d->mBirthdateWidget->date(), QTime(), contact.birthday().timeSpec() );
>   birthday.setTime( QTime() );
>   contact.setBirthday( birthday );
> 
> stores the datetime with an invalid time, and results in the it being saved as date only in the Akonadi storage and the vCard export (with no special patch).
> 
> The only other possible ramification of this change is that the stored QDateTime is no longer valid (i.e. isValid()==false therefore toString()==""), but the date can still be retrieved via date().  Not sure whether this will affect anything else within kdepim.
> 
> If the 1-line patch works then there is no need for this export patch, so if the entered birthday does gain the option of setting a time in future then it will be exported as intended.  Would this be an acceptable fix?
> 
My opinion is that your 1-line fix is the right thing, if we indeed want the birth datetime
to have an invalid QTime component.

And annivesaries aren't affected?  Seems strange that birthdays and anniversaries aren't
handled in the same way.

Anyway, commit is ok with me.  

FWIW, I checked the birthdays resource and it does use .date() so at least we know
the birthdays resource will still work.

-Allen

_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list