Skip to content

Commit

Permalink
refs #45 use contact incomplete birthday
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
  • Loading branch information
Julien Veyssier committed Jan 6, 2021
1 parent 0b45a18 commit 6830078
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Service/GoogleContactsAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ public function importContacts(string $accessToken, string $userId, ?string $uri
$type = ['VALUE' => 'DATE'];
$prop = $vCard->createProperty('BDAY', $strDate, $type);
$vCard->add($prop);
} elseif (isset($birthday['date'], $birthday['date']['month'], $birthday['date']['day'])) {
$type = ['VALUE' => 'DATE'];
$month = $birthday['date']['month'];
$month = strlen($month) === 2 ? $month : '0' . $month;
$day = $birthday['date']['day'];
$day = strlen($day) === 2 ? $day : '0' . $day;
if (strlen($month) === 2 && strlen($day) === 2) {
$prop = $vCard->createProperty('BDAY', '--' . $month . $day, $type);
$vCard->add($prop);
}
} elseif (isset($birthday['text']) && is_string($birthday['text'])) {
$type = ['VALUE' => 'text'];
$prop = $vCard->createProperty('BDAY', $birthday['text'], $type);
Expand Down

0 comments on commit 6830078

Please sign in to comment.