$year = $this->get('dob_year');
if (!$year)
{
$year = 2008; // pick a leap year to be sure
}
else if ($year < 100)
{
$year += ($year < 30 ? 2000 : 1900);
$this->set('dob_year', $year);
}
if ($year > intval(date('Y'))
|| $year < 1900
|| !checkdate($this->get('dob_month'), $this->get('dob_day'), $year)
|| gmmktime(0, 0, 0, $this->get('dob_month'), $this->get('dob_day'), $year) > XenForo_Application::$time + 86400 // +1 day to be careful with TZs ahead of GMT
)
{
if ($this->_importMode)
{
// don't error, wipe it out
$this->set('dob_day', 0);
$this->set('dob_month', 0);
$this->set('dob_year', 0);
}
else
{
$this->error(new XenForo_Phrase('please_enter_valid_date_of_birth'), 'dob');
}
return false;
}