/** * Check the equality of a DateAndTime against a PHP DateTime object * * @param object DateAndTime $dateAndTime * @param object DateTime $dateTime * @return void * @access protected * @since 11/21/08 */ protected function checkEquality(DateAndTime $dateAndTime, DateTime $dateTime) { print "<h4>" . $dateAndTime->asString() . "</h4>"; print "Year: "; $this->assertEqual($dateAndTime->year(), intval($dateTime->format('Y'))); print "Month: "; $this->assertEqual($dateAndTime->month(), intval($dateTime->format('n'))); print "Day of Month: "; $this->assertEqual($dateAndTime->dayOfMonth(), intval($dateTime->format('j'))); print "Day of Year: "; $this->assertEqual($dateAndTime->dayOfYear() - 1, intval($dateTime->format('z'))); print "Hour: "; $this->assertEqual($dateAndTime->hour(), intval($dateTime->format('G'))); print "Minute: "; $this->assertEqual($dateAndTime->minute(), intval($dateTime->format('i'))); print "Second: "; $this->assertEqual($dateAndTime->second(), intval($dateTime->format('s'))); // print "TZ abbriviation: "; // $this->assertEqual($dateAndTime->timeZoneAbbreviation(), $dateTime->format('T')); $datTZone = $dateAndTime->timeZone(); $dtTZone = $dateTime->getTimezone(); print "TZ seconds: "; $this->assertEqual($datTZone->offset()->asSeconds(), intval($dateTime->format('Z'))); }
/** * Forcibly set the creation date of this Asset. This is meant to be used when importing * from backups. * * WARNING: NOT IN OSID * * @param object DateAndTime $date * @return void * @access public * @since 1/25/08 */ public function forceSetModificationDate(DateAndTime $date) { $dbHandler = Services::getService("DatabaseManager"); $query = new UpdateQuery(); $query->setTable("dr_asset_info"); $query->addValue("modify_timestamp", $date->asString()); $query->addWhere("asset_id='" . $this->getId()->getIdString() . "'"); $dbHandler->query($query, $this->_dbIndex); $this->_modifyDate = $date; }
/** * Import a historical version, for instance from a backup system. * * @param object DOMDocument $versionXml The version markup. * @param object Id $agentId The agent id that created the version. * @param object DateAndTime $timestamp The time the version was created. * @param string $comment A comment associated with the version. * @return void * @access public * @since 1/23/08 */ public function importVersion(DOMDocument $versionXml, Id $agentId, DateAndTime $timestamp, $comment) { $query = new InsertQuery(); $query->setTable('segue_plugin_version'); $query->addValue('node_id', $this->getId()); $query->addValue('tstamp', $timestamp->asString()); $query->addValue('agent_id', $agentId->getIdString()); $query->addValue('comment', $comment); $query->addValue('version_xml', $versionXml->saveXML()); $dbc = Services::getService('DBHandler'); $dbc->query($query, IMPORTER_CONNECTION); unset($this->versions); }