Fixed Import from SMF wrong birthdays?

Mr. Jinx

Well-known member
I did a (test) import with SMF 2.0.13 data. Not sure if this is a bug or something else so I'll post it here.
Birthdays are not imported properly. Most of them are imported with year 1900 and a wrong month/day.

This is probably a date conversion thing. Anyone know about this?
 
What is the format of birth dates for the users in the SMF database which haven't been imported correctly?
 
Hmm, our code expects it to be "day-month-year", e.g. 22-05-1974

Do you know if this is something that has changed in recent years, or is configurable by the admin or can be stored differently based on localisation settings?
 
Then again, why did nobody complain about this before... weird.
This is definitely the important question. I don't recall that being mentioned before, which is bizarre as it has almost certainly been wrong for 2.5 years.

Hence why I assumed there must be some change or some setting (which would be especially odd considering its purpose).

Anyway, if you wanted to fix this for yourself and do the import again:

In library/XenForo/Importer/SMF.php change:
PHP:
if (trim($parts[2]) != '0001')
To:
PHP:
if (trim($parts[0]) != '0001')

Change:
PHP:
$import['dob_day'] = trim($parts[0]);
To:
PHP:
$import['dob_day'] = trim($parts[2]);

Change:
PHP:
$import['dob_year'] = trim($parts[2]);
To:
PHP:
$import['dob_year'] = trim($parts[0]);

And that should fix it.

If you're not planning to do another import, can you confirm what the dob_day, dob_month and dob_year fields have been imported as in XF? I'm hoping 1974, 5 and 22 respectively. If that's the case, we might be able to direct a SQL query to fix them, otherwise they'll be stuck like that or need resetting.
 
Then again, why did nobody complain about this before... weird.

This is definitely the important question. I don't recall that being mentioned before, which is bizarre as it has almost certainly been wrong for 2.5 years.
I can confirm that when I converted several years ago all dates were converted correctly. I don't remember what version of SMF I was converting from at the time but the converter worked correctly at that time.
 
I get funky birthdates Xenforo after an SMF 2.0.13 import, too. Just like @Mr. Jinx , the smf_members.birthdate column is in a YYYY-MM-DD format. I have been making preparations to migrate from SMF since February and thought, given the silence about importing birthdays, that it must've just been a quirk with my instance of SMF. Up to now I've run queries to update the xf_user_profile dob year/month/day columns after import, but I'll give the Importer/SMF.php edits a shot as it will save some time - thanks @Chris D :).

SMF stores some birthdays with the year '0004', in cases where somebody has entered their birthday with the year omitted. Looking at Importer/SMF.php this doesn't appear to be taken into consideration. I'm guessing all this probably needs is the following condition added before $import['dob_year']:
PHP:
if (trim($parts[0]) != '0004')
 
The fix from Chris D worked for me. I also had some birthdays with 0004 and changed those manually.
I also had some other problems with the importer, not related to birthdays. Maybe I'll write a small 'lessons learned' or something about my experiences.
 
The fix from Chris D worked for me. I also had some birthdays with 0004 and changed those manually.
I also had some other problems with the importer, not related to birthdays. Maybe I'll write a small 'lessons learned' or something about my experiences.

Yeah I also have to run my own queries for user timezones as they don't import from SMF correctly either, with many defaulting to "Atlantic/Reykjavik" and not the SMF configured server time "Australia/Sydney" (although this is getting off topic sorry). :)
 
For what it's worth, I have SMF 2.1 Beta 2 installed for a site and the default birthdate format is definitely 0001-01-01.
 
Back
Top Bottom