Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     static::$date = REQUEST_TIME + 86400;
     // Set the timezone.
     date_default_timezone_set(static::$timezone);
     // Add some basic test nodes.
     $dates = ['2000-10-10T00:01:30', '2001-10-10T12:12:12', '2002-10-10T14:14:14', \Drupal::service('date.formatter')->format(static::$date, 'custom', DATETIME_DATETIME_STORAGE_FORMAT, DATETIME_STORAGE_TIMEZONE)];
     foreach ($dates as $date) {
         $this->nodes[] = $this->drupalCreateNode(['field_date' => ['value' => $date]]);
     }
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  *
  * Create nodes with relative dates of yesterday, today, and tomorrow.
  */
 public function setUp()
 {
     parent::setUp();
     // Set to 'today'.
     static::$date = REQUEST_TIME;
     // Change field storage to date-only.
     $storage = FieldStorageConfig::load('node.' . static::$field_name);
     $storage->setSetting('datetime_type', DateTimeItem::DATETIME_TYPE_DATE);
     $storage->save();
     $dates = [\Drupal::service('date.formatter')->format(static::$date + 86400, 'custom', DATETIME_DATE_STORAGE_FORMAT, DATETIME_STORAGE_TIMEZONE), \Drupal::service('date.formatter')->format(static::$date, 'custom', DATETIME_DATE_STORAGE_FORMAT, DATETIME_STORAGE_TIMEZONE), \Drupal::service('date.formatter')->format(static::$date - 86400, 'custom', DATETIME_DATE_STORAGE_FORMAT, DATETIME_STORAGE_TIMEZONE)];
     foreach ($dates as $date) {
         $this->nodes[] = $this->drupalCreateNode(['field_date' => ['value' => $date]]);
     }
 }
Exemplo n.º 3
0
 /**
  * Set enable or disable auto fillable
  * "created_at" and "updated_at" date field
  *
  * @param  boolean $bool
  * @return void
  */
 public static function date($bool)
 {
     static::$date = (bool) $bool;
 }