Format birthday as BDAY;VALUE=DATE:YYYY-MM-DD. Fixes oc-1276.

This commit is contained in:
Thomas Tanghus 2012-07-16 23:36:11 +02:00
parent 47566b0c42
commit f128b96ac0
1 changed files with 9 additions and 2 deletions

View File

@ -66,8 +66,7 @@ if($element != $name) {
switch($element) { switch($element) {
case 'BDAY': case 'BDAY':
$date = New DateTime($value); $date = New DateTime($value);
//$vcard->setDateTime('BDAY', $date, Sabre_VObject_Element_DateTime::DATE); $value = $date->format('Y-m-d');
$value = $date->format(DateTime::ATOM);
break; break;
case 'FN': case 'FN':
if(!$value) { if(!$value) {
@ -89,6 +88,14 @@ if(!$value) {
} else { } else {
/* setting value */ /* setting value */
switch($element) { switch($element) {
case 'BDAY':
// I don't use setDateTime() because that formats it as YYYYMMDD instead of YYYY-MM-DD
// which is what the RFC recommends.
$vcard->children[$line]->setValue($value);
$vcard->children[$line]->parameters = array();
$vcard->children[$line]->add(new Sabre_VObject_Parameter('VALUE', 'DATE'));
debug('Setting value:'.$name.' '.$vcard->children[$line]);
break;
case 'CATEGORIES': case 'CATEGORIES':
debug('Setting string:'.$name.' '.$value); debug('Setting string:'.$name.' '.$value);
$vcard->children[$line]->setValue($value); $vcard->children[$line]->setValue($value);