You are here

function _quiz_form_prepare_date in Quiz 5

Same name and namespace in other branches
  1. 8.4 quiz.module \_quiz_form_prepare_date()
  2. 5.2 quiz.module \_quiz_form_prepare_date()
  3. 6.6 quiz.module \_quiz_form_prepare_date()
  4. 6.2 quiz.module \_quiz_form_prepare_date()
  5. 6.3 quiz.module \_quiz_form_prepare_date()
  6. 6.4 quiz.module \_quiz_form_prepare_date()
  7. 6.5 quiz.module \_quiz_form_prepare_date()
  8. 7 quiz.module \_quiz_form_prepare_date()
  9. 7.4 quiz.module \_quiz_form_prepare_date()

Takes a time element and prepares to send it to form_date()

Parameters

$time: The time to be turned into an array. This can be:

  • a timestamp when from the database
  • an array (day, month, year) when previewing
  • null for new nodes

Return value

an array for form_date (day, month, year)

1 call to _quiz_form_prepare_date()
quiz_form in ./quiz.module
Implementation of hook_form().

File

./quiz.module, line 301
Quiz Module

Code

function _quiz_form_prepare_date($time = '', $offset = 0) {

  // if this is empty, get the current time
  if ($time == '') {
    $time = time();
    $time = strtotime("+{$offset} days", $time);
  }

  // If we are previewing, $time will be an array so just pass it through
  $time_array = array();
  if (is_array($time)) {
    $time_array = $time;
  }
  elseif (is_numeric($time)) {
    $time_array = array(
      'day' => _quiz_date('j', $time),
      'month' => _quiz_date('n', $time),
      'year' => _quiz_date('Y', $time),
    );
  }

  // return the array
  return $time_array;
}