/** * Sets the time portion to the given time. If a QDateTime is given, will use the time portion of that object. * Works around a problem in php that if you set the time across a daylight savings time boundary, the timezone * does not advance. This version will detect that and advance the timezone. * * @param int|QDateTime $mixValue * @param int|null $intMinute * @param int|null $intSecond * @return QDateTime */ public function setTime($mixValue, $intMinute = null, $intSecond = null) { if ($mixValue instanceof QDateTime) { if ($mixValue->IsTimeNull()) { $this->blnTimeNull = true; $this->ReinforceNullProperties(); return $this; } // normalize the timezones $tz = $this->getTimezone(); if ($tz && in_array($tz->getName(), timezone_identifiers_list())) { // php limits you to ID only timezones here, so make sure we have one of those $mixValue->setTimezone($tz); } $intHour = $mixValue->Hour; $intMinute = $mixValue->Minute; $intSecond = $mixValue->Second; } else { $intHour = $mixValue; } // If HOUR or MINUTE is NULL... if (is_null($intHour) || is_null($intMinute)) { parent::setTime($intHour, $intMinute, $intSecond); $this->blnTimeNull = true; $this->ReinforceNullProperties(); return $this; } $intHour = QType::Cast($intHour, QType::Integer); $intMinute = QType::Cast($intMinute, QType::Integer); $intSecond = QType::Cast($intSecond, QType::Integer); $this->blnTimeNull = false; /* // Possible fix for a PHP problem. Can't reproduce, so leaving code here just in case it comes back. // The problem is with setting times across dst barriers if ($this->Hour == 0 && preg_match('/[0-9]+/', $this->getTimezone()->getName())) { // fix a php problem with GMT and relative timezones $s = 'PT' . $intHour . 'H' . $intMinute . 'M' . $intSecond . 'S'; $this->add (new DateInterval ($s)); // will continue and set again to make sure, because boundary crossing will change the time }*/ parent::setTime($intHour, $intMinute, $intSecond); return $this; }