You are here

function quiz_translate_form_date in Quiz 7

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. 5 quiz_datetime.inc \quiz_translate_form_date()
  4. 6.6 quiz_datetime.inc \quiz_translate_form_date()
  5. 6.2 quiz_datetime.inc \quiz_translate_form_date()
  6. 6.3 quiz_datetime.inc \quiz_translate_form_date()
  7. 6.4 quiz_datetime.inc \quiz_translate_form_date()
  8. 6.5 quiz_datetime.inc \quiz_translate_form_date()
  9. 7.6 quiz.module \quiz_translate_form_date()
  10. 7.4 quiz_datetime.inc \quiz_translate_form_date()
  11. 7.5 quiz.module \quiz_translate_form_date()

@file 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.:

1 call to quiz_translate_form_date()
_quiz_common_presave_actions in ./quiz.module
Common actions that need to be done before a quiz is inserted or updated

File

./quiz_datetime.inc, line 19
Handles the start and end times in a node form submission.

Code

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

  // If we have all the parameters, re-calculate $node->event_$date .
  if (is_array($prefix) && 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 {
    if (!_quiz_is_int($prefix, 1, 2147483647)) {
      form_set_error('quiz_open', t('Please supply a valid date.'));
    }
  }
}