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

Jonathan Marten jjm at keelhaul.me.uk
Thu Jan 26 12:43:17 GMT 2012



> On Jan. 23, 2012, 6:05 p.m., Kevin Krammer wrote:
> > Just to be sure I understand this correctly: do certain applications have a problem with parsing a time in the BDAY field or are they just not accepting midnight UTC?
> > If they are generally incapable of dealing with standard VCard and are unlikely to be fixed we should probably consider them a special export format instead.
> 
> Jonathan Marten wrote:
>     For those that I am able to test - Android and Gmail - it appears that the presence of the time is the problem, not it being set to midnight.  The vCard file
>     
>     BEGIN:VCARD
>     BDAY:1965-04-10T01:02:03Z
>     EMAIL;TYPE=PREF:foo at bar.com
>     FN:Foo Bar
>     N:Bar;Foo;;;
>     UID:M5VE64gMYm
>     VERSION:3.0
>     END:VCARD
>     
>     fails to import the birthday;  however if the 2nd line is changed to
>     
>     BDAY:1965-04-10
>     
>     then that date is imported correctly.
>     
>     I'm not convinced that having to have a special export format just to cover these - which are not exactly obscure applications - is the right approach.  There is no GUI and no facility for time-of-birthday to be entered in KAddressBook, so anything output here is pure invention anyway.  Even with the time removed, the resulting vCard is still standards compliant in every way so there should be no reason to have a special format.
> 
> Kevin Krammer wrote:
>     While those applications are not obscure they are obviously buggy. If we want to support buggy recipients of our data we should do that in a way that does not block us from supporting standard complient ones.
>     
>     While I think we should check that our importing code does not add time information to a date only birthday, we should not discard already present time information without being able to check whether it is valid. 
>     Export into what is the application's default format might be used for backup purposes and should IMHO not drop data that cannot be recreated at import.
>

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?


- Jonathan


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/103776/#review10025
-----------------------------------------------------------


On Jan. 23, 2012, 8:27 p.m., Jonathan Marten wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/103776/
> -----------------------------------------------------------
> 
> (Updated Jan. 23, 2012, 8:27 p.m.)
> 
> 
> Review request for KDEPIM.
> 
> 
> Description
> -------
> 
> The referenced bugs refer to the BDAY field in an exported vCard including a time field of midnight, even though the user will not have entered this in KAddressBook and there is no GUI to do so:
> 
> BDAY:1978-07-20T00:00:00Z
> 
> This is valid according to RFC2426, but unfortunately some receiving applications - notably GMail and Android - do not recognise the birthday field in this format and ignore it.  If the time part is removed:
> 
> BDAY:1978-07-20
> 
> then the birthday date is recognised.
> 
> This patch implements that, only for vCard export from KAddressBook.  It does not modify or change the behaviour of the KABC library, so not affecting any other applications that may use this format with a valid time (and kdelibs is frozen now anyway).
> 
> 
> This addresses bugs 118289 and 282169.
>     http://bugs.kde.org/show_bug.cgi?id=118289
>     http://bugs.kde.org/show_bug.cgi?id=282169
> 
> 
> Diffs
> -----
> 
>   kaddressbook/xxport/vcard/vcard_xxport.cpp bb4211b 
> 
> Diff: http://git.reviewboard.kde.org/r/103776/diff/diff
> 
> 
> Testing
> -------
> 
> Build kdepim with these changes, checked vCard export by visual inspection of the output and by import into GMail Contacts.
> 
> 
> Thanks,
> 
> Jonathan Marten
> 
>

_______________________________________________
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