When creating an event, the time selected is not saved correctly.

Comments

usharf’s picture

Component: Code » User interface

I have the same problem with AM/PM, all hours are treted as AM, event though site is used to diaply 24hrs format.

mikeryan’s picture

I'm running with 12-hour (am/pm) time and Timezone Handling set to No. My only problem is with times from noon to 12:59pm - they are displayed (and sorted) as am.

seanr’s picture

Priority: Normal » Critical

Conformed. I also had one person say that their event showed as 11am no matter what time they put in, but when I went in and set it to 3pm, it worked. This is a _critical_ bug that must be fised sooner rather than later - it's effecting live sites and making it very difficult to post events!

seanr’s picture

confirmed, even. LOL

mikeryan’s picture

I've tweaked my copy of event.module, so I can't provide a patch for just this problem, but here's a version of event_validate() that addresses this problem:

function event_validate(&$node) {
  // Re-calculate $node->start if we have all the parameters.
  if (isset($node->year) && isset($node->month) && isset($node->day) && isset($node->hour) && isset($node->minute)) {
    $hour = $node->hour;
    if (variable_get('event_ampm', '0')) {
      if ($node->ampm == 'pm') {
        if ($hour != 12) $hour += 12;
      }
      elseif ($hour == 12) {
        $hour -= 12;
      }
    }
    $node->start = _event_mktime($hour, $node->minute, 0, $node->month, $node->day, $node->year);
    if (variable_get('event_timezone', '1')) {
      $node->start -= $GLOBALS['user']->timezone;
    }
  }

  if (empty($node->start)) {
    $node->start = time();
    // Round to nearest hour:
    $node->start -= $node->start % (60 * 60);
  }

  $fields = event_fields();
  foreach ($fields as $field => $def) {
    if ($def[2] && empty($node->$field)) {
      $error[$field] = t("Required.");
    }
  }

  return $error;
}

killes@www.drop.org’s picture

fixed in 4.6

Anonymous’s picture