Skip to content

Commit

Permalink
Fix X-APPLE-OMIT-YEAR extensions on birthdays without year
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-athome committed Sep 25, 2023
1 parent 3501872 commit af17c2e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion immich_carddav_sync/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,18 @@ async def fetch_carddav_addressbook(url: str, collection: str, username: str, pa
raise NotImplementedError('Duplicate contacts cannot be handled yet ("%s").' % vcard.fn.value)

try:
names[vcard.fn.value] = datetime.date.fromisoformat(vcard.bday.value).isoformat()
birthday = datetime.date.fromisoformat(vcard.bday.value)
try:
omit_year = vcard.bday.params["X-APPLE-OMIT-YEAR"][0]
if str(birthday.year) == omit_year:
# birthday without year, skip
raise ValueError
except (KeyError, IndexError):
# no omit year, all fine!
pass

names[vcard.fn.value] = birthday.isoformat()

except ValueError:
# invalid date
pass
Expand Down

0 comments on commit af17c2e

Please sign in to comment.