Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A workaround for shifting Address Book birthdays Apps
OS X uses timezoned dates (NSCalendarDate) for representing birthdays in Address Book. This means that if you create a birthday in one time zone, and then shift to a very different time zone (e.g. NZST/Auckland to US/Pacific), all of your birthdays will shift by a day! I don't know about you, but when I move overseas I don't want my birthday changing dates! Plus it is confusing to have them all moving about -- if I need a time conversion to figure out when to phone them, I'll do it myself as OS X doesn't know what timezone they are living in.

To work around this problem, I hacked together a python script which moves all your birthdays by any number of days in either direction. You'll need pyobjc installed to make this work, since it uses the Cocoa AddressBook framework. I have Pyobjc version 1.3.6 for python 2.3. If you have entered various birthdays in various time zones, you might find only some birthdays move around. This script won't help you with that. Maybe someone wants to write one that normalises birthdays to a unified timezone.

Put the code in a text file called correctBirthdays and make it executable (chmod 755 correctBirthdays). Run it from Terminal and give it the number of days to shift birthdays by as an argument. For example, the following will move all birthdays back by one day:
./correctBirthdays -1
Needless to say, back up your Address Book before you try this!

[robg adds: I haven't tested this one.]
    •    
  • Currently 1.50 / 5
  You rated: 2 / 5 (2 votes cast)
 
[8,428 views]  

A workaround for shifting Address Book birthdays | 6 comments | Create New Account
Click here to return to the 'A workaround for shifting Address Book birthdays' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
iCal is correct
Authored by: iamacat on Mar 15, '07 12:03:02PM

When you were born, some of the world had a different date on the calendar. Conversely, if you want to congratulate your friend, you may need to call one day early or late depending on where you and he/she lives.



[ Reply to This | # ]
iCal is not correct
Authored by: tancurl on Mar 15, '07 01:26:20PM
iCal is not correct.

The actual point in time at which people celebrate their birthdays depends on what timezone they are in, not which timezone you are in.

To deal with this I guess you could individually adjust everyone's birthday - e.g if you are in the US and you have a friend in Britan, you could enter the US date at which their birthday will actually be occuring, rather then the birthday they will be experiencing if they were with you in the US. If they move to Australia, you could go and adjust their birthday again.

But are you seriously going to adjust each and everyone of your contacts birthdays each and everytime they move from one country to another? I don't know about you, but I have friends and family all around the world, and many of them are often travelling around.

So the best solution is for AddressBook to just keep the nominal birthdate that you enter, and not shift it around. That way when you see a birthday coming up you can figure out what timezone they are in yourself.



[ Reply to This | # ]

No, this is a bug
Authored by: boxcarl on Mar 15, '07 01:26:22PM

You would have a point if the birthday field of Address Book allowed us to input a time of birth along with a date. It does not. Therefore, the birthdays should not be moved.

This bug is really annoying too, since the whole reason I started putting birthdays into the Address Book was because I didn't want to remember them myself. When birthdays start wandering around (seemingly) at random, how am I supposed to even know besides asking people what their birthday is again? Apple screwed this one up.



[ Reply to This | # ]
iCal is correct
Authored by: tancurl on Mar 15, '07 01:44:58PM

Also, birthdays should never move dates as timezones mean days in different countries actually overlap.

For example if you are in Vancouver and your Mum's birthday is Jan 1st and she is in Australia, her birthday will be your evening of the Dec 31st and run into Jan 1st. In this case it makes no sense for iCal to display her birthday as Dec 31st as you could phone her on the evening of the 31st or the morning of Jan 1st and still talk to her on her birthday...

iCal shifting birthdays just makes figuring these things out even more complicated!



[ Reply to This | # ]
Timezone aware version - use this instead
Authored by: tancurl on Mar 15, '07 01:35:04PM
Here is a timezone aware version of the script you should use instead.

It shifts all the timezones of birthdays to your current timezone, meaning the day displays the same no matter what timezone you are in.

This means that if you enter a birthday as 1st Jan, then no matter what timezone you move to you can ensure it will still display at 1st Jan buy running the script

Also, if you entered peoples birthdays while you were in different timezones you can find that certain timezone changes will move only some birthdays. Luckly this script will fix that problem too.


#!/usr/bin/env python2.3

import AddressBook
import sys
import Foundation

book = AddressBook.ABAddressBook.sharedAddressBook()
addressBookPeople = book.people()

birthdaysChanged = 0;

currentTimeZone = Foundation.NSTimeZone.systemTimeZone()

for person in addressBookPeople:
	birthday = person.valueForProperty_('Birthday')
	if (type(birthday) == AddressBook.NSCalendarDate):
		"""They have a birthday"""
		
		newBirthday = Foundation.NSCalendarDate.alloc().initWithYear_month_day_hour_minute_second_timeZone_(
			birthday.yearOfCommonEra(), 
			birthday.monthOfYear(), 
			birthday.dayOfMonth(), 
			birthday.hourOfDay(), 
			birthday.minuteOfHour(), 
			birthday.secondOfMinute(), 
			currentTimeZone)

		person.setValue_forProperty_(newBirthday,"Birthday")
		birthdaysChanged = birthdaysChanged + 1;

if (birthdaysChanged > 0):
	AddressBook.ABAddressBook.sharedAddressBook().save()
	print str(birthdaysChanged) + " birthdays changed and saved."
else:
	print "No birthdays changed!"


[ Reply to This | # ]
Timezone aware version - use this instead
Authored by: bex on Apr 20, '10 06:07:30PM

Running this under the most current Snow Leopard is not seeming to change the TimeZone of any of my birthday entries. I still have a mish-mash of entries in either -0500 or -0400. This is causing the birthdays to misread by a day when DST is in effect.

Any advice?

regards

bex



[ Reply to This | # ]