You are here

class EasyRdf_Literal_DateTime in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/DateTime.php \EasyRdf_Literal_DateTime

Class that represents an RDF Literal of datatype xsd:dateTime

@package EasyRdf @link http://www.w3.org/TR/xmlschema-2/#date @copyright Copyright (c) 2009-2013 Nicholas J Humfrey @license http://www.opensource.org/licenses/bsd-license.php

Hierarchy

Expanded class hierarchy of EasyRdf_Literal_DateTime

1 string reference to 'EasyRdf_Literal_DateTime'
Literal.php in vendor/easyrdf/easyrdf/lib/EasyRdf/Literal.php

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/DateTime.php, line 46

View source
class EasyRdf_Literal_DateTime extends EasyRdf_Literal_Date {

  /** 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.
   * If no value is given or is is null, then the current time is used.
   *
   * @see DateTime
   *
   * @param  mixed  $value     The value of the literal
   * @param  string $lang      Should be null (literals with a datatype can't have a language)
   * @param  string $datatype  Optional datatype (default 'xsd:dateTime')
   * @return object EasyRdf_Literal_DateTime
   */
  public function __construct($value = null, $lang = null, $datatype = null) {

    // If $value is null, use 'now'
    if (is_null($value)) {
      $value = new DateTime('now');
    }

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

  /** Parses a string using DateTime and creates a new literal
   *
   * Example:
   *   $dt = EasyRdf_Literal_DateTime::parse('Mon 18 Jul 2011 18:45:43 BST');
   *
   * @see DateTime
   * @param string $value The date and time to parse
   * @return object EasyRdf_Literal_DateTime
   */
  public static function parse($value) {
    $value = new DateTime($value);
    return new EasyRdf_Literal_DateTime($value);
  }

  /** 24-hour format of the hour as an integer
   *
   * @return integer
   */
  public function hour() {
    return (int) $this
      ->format('H');
  }

  /** The minutes pasts the hour as an integer
   *
   * @return integer
   */
  public function min() {
    return (int) $this
      ->format('i');
  }

  /** The seconds pasts the minute as an integer
   *
   * @return integer
   */
  public function sec() {
    return (int) $this
      ->format('s');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EasyRdf_Literal::$classMap private static property @ignore A mapping from class name to datatype URI
EasyRdf_Literal::$datatype protected property @ignore The datatype URI of the literal
EasyRdf_Literal::$datatypeMap private static property @ignore a mapping from datatype uri to class name
EasyRdf_Literal::$lang protected property @ignore The language of the literal (e.g. 'en')
EasyRdf_Literal::$value protected property @ignore The string value for this literal
EasyRdf_Literal::create public static function Create a new literal object
EasyRdf_Literal::deleteDatatypeMapping public static function Remove the mapping between an RDF datatype and a PHP class name
EasyRdf_Literal::dumpValue public function Return pretty-print view of the literal
EasyRdf_Literal::getDatatype public function Returns the shortened datatype URI of the literal.
EasyRdf_Literal::getDatatypeForValue public static function Get datatype URI for a PHP value.
EasyRdf_Literal::getDatatypeUri public function Returns the full datatype URI of the literal.
EasyRdf_Literal::getLang public function Returns the language of the literal.
EasyRdf_Literal::setDatatypeMapping public static function Register an RDF datatype with a PHP class name
EasyRdf_Literal::toRdfPhp public function Returns the properties of the literal as an associative array
EasyRdf_Literal::__toString public function Magic method to return the value of a literal as a string
EasyRdf_Literal_Date::day public function Integer representation of the day of the month
EasyRdf_Literal_Date::format public function Returns date formatted according to given format
EasyRdf_Literal_Date::getValue public function Returns the date as a PHP DateTime object Overrides EasyRdf_Literal::getValue
EasyRdf_Literal_Date::month public function Integer representation of the month
EasyRdf_Literal_Date::year public function A full integer representation of the year, 4 digits
EasyRdf_Literal_DateTime::hour public function 24-hour format of the hour as an integer
EasyRdf_Literal_DateTime::min public function The minutes pasts the hour as an integer
EasyRdf_Literal_DateTime::parse public static function Parses a string using DateTime and creates a new literal Overrides EasyRdf_Literal_Date::parse
EasyRdf_Literal_DateTime::sec public function The seconds pasts the minute as an integer
EasyRdf_Literal_DateTime::__construct public function Constructor for creating a new date and time literal Overrides EasyRdf_Literal_Date::__construct