コード例 #1
0
 /**
  * @param Schema $schema
  * @return void
  */
 public function up(Schema $schema)
 {
     $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
     $now = new Now();
     $default = $now->format($this->platform->getDateTimeFormatString());
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_nodedata ADD creationdatetime DATETIME NOT NULL, ADD lastmodificationdatetime DATETIME NOT NULL, ADD lastpublicationdatetime DATETIME DEFAULT NULL");
     $this->addSql("UPDATE typo3_typo3cr_domain_model_nodedata SET creationdatetime = '" . $default . "', lastmodificationdatetime = '" . $default . "'");
     $this->addSql("UPDATE typo3_typo3cr_domain_model_nodedata SET lastpublicationdatetime = '" . $default . "' WHERE workspace = 'live'");
 }
コード例 #2
0
 /**
  * @param Schema $schema
  * @return void
  */
 public function up(Schema $schema)
 {
     $this->abortIf($this->connection->getDatabasePlatform()->getName() != "postgresql");
     $now = new Now();
     $default = $now->format($this->platform->getDateTimeFormatString());
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_nodedata ADD creationdatetime TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL DEFAULT '" . $default . "'");
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_nodedata ALTER COLUMN creationdatetime DROP DEFAULT");
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_nodedata ADD lastmodificationdatetime TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL DEFAULT '" . $default . "'");
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_nodedata ALTER COLUMN lastmodificationdatetime DROP DEFAULT");
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_nodedata ADD lastpublicationdatetime TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL");
     $this->addSql("UPDATE typo3_typo3cr_domain_model_nodedata SET lastpublicationdatetime = '" . $default . "' WHERE workspace = 'live'");
 }
 /**
  * Renders a DateTime formatted relative to the current date.
  * Shows the time if the date is the current date.
  * Shows the month and date if the date is the current year.
  * Shows the year/month/date if the date is not the current year.
  *
  * @param \DateTime $date
  * @return string an <img...> html tag
  * @throws \InvalidArgumentException
  */
 public function render(\DateTime $date = null)
 {
     if ($date === null) {
         $date = $this->renderChildren();
     }
     if (!$date instanceof \DateTime) {
         throw new \InvalidArgumentException('No valid date given,', 1424647058);
     }
     // More than 11 months ago
     $now = new Now();
     if ($date < $now->modify('-11 months')) {
         return $date->format('Y M j');
     }
     // Same day of same year
     $now = new Now();
     if ($date->format('Y z') === $now->format('Y z')) {
         return $date->format('H:i');
     }
     return $date->format('M j');
 }