birthday_date always returning 1/1/1900

Nov 25, 2008 at 4:44 AM
Anyone tried the birthday_date field for a friend? (via API.friends.getUserObjects()). Birthdays for friends (a DateTime field) always returns 1/1/1900. Well, this isn't 100% correct. *Some* of my friends return other dates, but they're all before 1902.
Nov 25, 2008 at 1:49 PM
You'll see this behavior when a friend does not supply all or part of his or her birthday.  If he or she only supplies the birthday, but not year, you might end up with something like Nov 25th, 1900.  If he or she does not specify anything, the birthday will be 1/1/1900. 

Hope this helps,
Nov 25, 2008 at 2:23 PM

I would agree with that except that:

* All of my friends (200+) of them have no birthday. I fail to agree that's the case with all of them as it's pretty unlikely
* I printed out user.birthday_date for my own account and got the same result (even though I was the logged in user and I do provide my full birthday to Facebook).
Dec 1, 2008 at 2:58 AM
I seem to remember seeing an issue about this a while back. I thought an issue had been logged, but I guess not. I'll go ahead and log a new issue.
Dec 2, 2008 at 10:15 PM
This FQL should show you the data just specify your own userid:

SELECT birthday FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = <user_id>)

I agree, they all shouldn't appear as 1/1/1900.
Dec 3, 2008 at 4:25 PM
Edited Dec 3, 2008 at 4:46 PM
I got a chance to debug this and the birthday_date property needs some improvement. I'm never seeing a double returned as the birthday for any of my friends (as a comment in the code suggests) so the logic ends up creating a string that's seemingly never "parseable" which is why you always end up with 1/1/1900. I haven't fully thought through what the logic should be but variations in birthday values I'm seeing include:

"July 10"
"July 10, 1982"

Also, if 1901 is going to be appended then the documentation should clearly state the situation.

The following seems to work better but I'm not overly fond of the solution even though I wrote it (albeit quickly). Btw, I wish the formatting of the FDT source was a bit better the tabbing/spacing seem to be a bit of a mess. Anyhoo...

public DateTime birthday_date
        double dblBirthDay;
        string birthday = this.birthday;
        if (Double.TryParse(birthday, out dblBirthDay))
          return DateHelper.ConvertDoubleToDate(dblBirthDay);
        DateTime bdate;
        if (birthday.Length == 0)
            return new DateTime(1900, 1, 1);
        if (Regex.IsMatch(birthday, "[A-Za-z]+\\s[0-9]{1,2},\\s[0-9]{4}"))
            if (DateTime.TryParse(birthday, out bdate))
                return bdate;
            if (Regex.IsMatch(birthday, "[A-Za-z]+\\s[0-9]{1,2}"))
                if (DateTime.TryParse(birthday + " 1901", out bdate))
                    return bdate;
      return new DateTime(1900,1,1);