class Date

The date data type.

The plain value of a date is an instance of the DrupalDateTime class. For setting the value any value supported by the __construct() of the DrupalDateTime class will work, including a DateTime object, a timestamp, a string date, or an array of date parts.

Hierarchy

Expanded class hierarchy of Date

19 string references to 'Date'
Date::get_sort_name in drupal/core/modules/views/lib/Drupal/views/Plugin/views/argument/Date.php
Return a description of how the argument would normally be sorted.
dblog_event in drupal/core/modules/dblog/dblog.admin.inc
Page callback: Displays details about a specific database log message.
dblog_overview in drupal/core/modules/dblog/dblog.admin.inc
Page callback: Displays a listing of database log messages.
HttpCache::validate in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
Validates that a cache entry is fresh.
HttpCacheTest::testCachesResponsesWithAMaxAgeDirective in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php

... See full list

File

drupal/core/lib/Drupal/Core/TypedData/Type/Date.php, line 22
Definition of Drupal\Core\TypedData\Type\Date.

Namespace

Drupal\Core\TypedData\Type
View source
class Date extends TypedData implements TypedDataInterface {

  /**
   * The data value.
   *
   * @var DateTime
   */
  protected $value;

  /**
   * Implements TypedDataInterface::setValue().
   */
  public function setValue($value) {

    // Don't try to create a date from an empty value.
    // It would default to the current time.
    if (!isset($value)) {
      $this->value = $value;
    }
    else {
      $this->value = $value instanceof DrupalDateTime ? $value : new DrupalDateTime($value);
      if ($this->value
        ->hasErrors()) {
        throw new InvalidArgumentException("Invalid date format given.");
      }
    }
  }

  /**
   * Implements TypedDataInterface::getString().
   */
  public function getString() {
    return (string) $this
      ->getValue();
  }

  /**
   * Implements TypedDataInterface::validate().
   */
  public function validate() {

    // TODO: Implement validate() method.
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Date::$value protected property The data value.
Date::getString public function Implements TypedDataInterface::getString(). Overrides TypedData::getString
Date::setValue public function Implements TypedDataInterface::setValue(). Overrides TypedData::setValue
Date::validate public function Implements TypedDataInterface::validate(). Overrides TypedDataInterface::validate
TypedData::$definition protected property The data definition.
TypedData::getDefinition public function Implements TypedDataInterface::getDefinition(). Overrides TypedDataInterface::getDefinition
TypedData::getType public function Implements TypedDataInterface::getType(). Overrides TypedDataInterface::getType
TypedData::getValue public function Implements TypedDataInterface::getValue(). Overrides TypedDataInterface::getValue 7
TypedData::__construct public function Constructs a TypedData object given its definition. 3