public function EasyRdf_Literal_DateTime::__construct

Constructor for creating a new date and time literal

If the value is a DateTime object, then it will be converted to the xsd:dateTime format.

Parameters

mixed $value The value of the literal:

string $lang Should be null (literals with a datatype can't have a language):

string $datatype Optional datatype (default 'xsd:dateTime'):

Return value

object EasyRdf_Literal_DateTime

Overrides EasyRdf_Literal_Date::__construct

See also

DateTime

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/DateTime.php, line 60

Class

EasyRdf_Literal_DateTime
Class that represents an RDF Literal of datatype xsd:dateTime

Code

public function __construct($value, $lang = null, $datatype = null) {

  // Convert DateTime objects into string
  if ($value instanceof DateTime) {
    $iso = $value
      ->format(DateTime::ISO8601);
    $value = preg_replace('/[\\+\\-]00(\\:?)00$/', 'Z', $iso);
  }
  EasyRdf_Literal::__construct($value, null, $datatype);
}