Can't determine when year is unknown with new Contact.birthday

[edited for clarity, to focus on my problems with Contact.birthday]

Starting with Scriptable 1.7.15 (Contact.dates) and 1.7.16 (Contact.birthday), the date objects fall back to using the current year when no year is set.

This breaks my script, which calculates people’s age for their upcoming birthday. Age is important for certain birthdays. But defaulting to the current year means that I can no longer distinguish between a new-born baby and someone whose actual birth year I don’t know.

The iOS version history for 1.7.15 notes that “the object returned by Contact.dates contains the date components used to construct the date, which can be used to detect cases where no year is available.”

However, I’m not able to find these components for Contact.birthday. And the Scriptable documentation is unfortunately no help, since the entirety of the birthday documentation is “birthday: Date”.

What do I need to do to distinguish between a birthday which happens in the current year, and one whose year is not stored in the Contacts database?

Contact.dates has this component to see what makes up the date that is output but Contact.birthday doesn’t seem to.

Example of Contact.dates output for a given contact without a year in the date.


Example of Contact.birthday for a contact without a year in the birthday

Wed Jan 24 2024 00:00:00 GMT-0500 (Eastern Standard Time)

Seems that the same logic wasn’t applied when Contact.birthday was updated / fixed. Arguable, but I’d rather the date be correct and not be able to distinguish if the year is present or not, than have the date be incorrect.

I will reply to Simon’s email about this fix and see if he can implement the similar logic for Contact.birthday

Yeah, the dateComponents object that Scriptable adds to each item in the Contact.dates array is very helpful. IT was also the reason that I edited my original post, because I hadn’t originally made a clear distinction between what did work and what didn’t work with these latest changes to Scriptable.

I confirm that it’s the lack of a similar structure for the Contact.birthday Date object which breaks my code. Previously, dates without a year were instanitated as Javascript Date objects with a value of 1 for the full year.

Previously, I did need to adjust the date by 48 hours in order to get the correct months/days (probably due to the way that the Gregorian calendar works – or rather, doesn’t work – in the year 1). But otherwise, everything worked well for me.

That would be great if you are able to contact Simon about this, thank you. Please let me know if he indicates that I should contact him for details. I’d posted to this forum first rather than contacting him, in hopes that this wouldn’t require creating a new support issue for him.

1 Like

Please do email him about your concerns from inside the app as well

Just did that now. I’d originally posted here to avoid adding to his backlog of support requests. But you’re right that it’s probably best to contact him directly about this issue.

1 Like