You are here

function user_import_profile_date in User Import 8

Same name and namespace in other branches
  1. 6.4 supported/profile.inc \user_import_profile_date()
  2. 6.2 supported/profile.inc \user_import_profile_date()
  3. 7 supported/profile.inc \user_import_profile_date()
  4. 7.2 supported/profile.inc \user_import_profile_date()

Convert date into format that Profile module expects: a:3:{s:5:"month";s:1:"1";s:3:"day";s:1:"1";s:4:"year";s:4:"1976";}

1 call to user_import_profile_date()
profile_user_import_save_profile in supported/profile.inc

File

supported/profile.inc, line 163

Code

function user_import_profile_date(&$value, $field_type) {
  if ($field_type != "date" || empty($value)) {
    return;
  }
  $date = explode('/', $value);
  if (!is_array($date)) {
    return;
  }

  // Get seleceted format.
  $date_format = variable_get('user_import_profile_date_format', 'MM/DD/YYYY');
  if ($date_format == 'MM/DD/YYYY') {
    list($month, $day, $year) = explode('/', $value);
  }
  else {
    if ($date_format == 'DD/MM/YYYY') {
      list($day, $month, $year) = explode('/', $value);
    }
    else {
      if ($date_format == 'YYYY/MM/DD') {
        list($year, $month, $day) = explode('/', $value);
      }
      else {
        if ($date_format == 'YYYY/DD/MM') {
          list($year, $day, $month) = explode('/', $value);
        }
      }
    }
  }

  // Leading zeros cause a problem so remove them.
  if (substr($day, 0, 1) == '0') {
    $day = substr($day, 1, 1);
  }
  if (substr($month, 0, 1) == '0') {
    $month = substr($month, 1, 1);
  }
  $value = serialize(array(
    'month' => $month,
    'day' => $day,
    'year' => $year,
  ));
}