You are here

function quiz_translate_form_date in Quiz 5

Same name and namespace in other branches
  1. 8.4 quiz_datetime.inc \quiz_translate_form_date()
  2. 5.2 quiz_datetime.inc \quiz_translate_form_date()
  3. 6.6 quiz_datetime.inc \quiz_translate_form_date()
  4. 6.2 quiz_datetime.inc \quiz_translate_form_date()
  5. 6.3 quiz_datetime.inc \quiz_translate_form_date()
  6. 6.4 quiz_datetime.inc \quiz_translate_form_date()
  7. 6.5 quiz_datetime.inc \quiz_translate_form_date()
  8. 7.6 quiz.module \quiz_translate_form_date()
  9. 7 quiz_datetime.inc \quiz_translate_form_date()
  10. 7.4 quiz_datetime.inc \quiz_translate_form_date()
  11. 7.5 quiz.module \quiz_translate_form_date()

Handles the start and end times in a node form submission.

  • Takes the array from form_date() and turns it into a timestamp
  • Adjusts times for time zone offsets.
  • Adapted from event.module

Parameters

$node The submitted node with form data.:

$date The name of the date ('quiz_open' or 'quiz_close') to translate.:

3 calls to quiz_translate_form_date()
quiz_insert in ./quiz.module
Implementation of hook_insert().
quiz_update in ./quiz.module
Implementation of hook_update().
theme_quiz_view in ./quiz.module
Theme the node view for quizzes

File

./quiz_datetime.inc, line 18

Code

function quiz_translate_form_date(&$node, $date) {
  $prefix = $node->{$date};

  // If we have all the parameters, re-calculate $node->event_$date .
  if (isset($prefix['year']) && isset($prefix['month']) && isset($prefix['day'])) {

    // Build a timestamp based on the date supplied and the configured timezone.
    $node->{$date} = _quiz_mktime(0, 0, 0, $prefix['month'], $prefix['day'], $prefix['year'], 0);
  }
  else {
    form_set_error('quiz_open', t('Please supply a valid date.'));
  }
}