fromString() public static method

Creates a Value from the given $dateString.
public static fromString ( string $dateString ) : Value
$dateString string
return Value
Beispiel #1
0
 /**
  * Converts an $hash to the Value defined by the field type
  *
  * @param mixed $hash Null or associative array containing timestamp and optionally date in RFC850 format.
  *
  * @return \eZ\Publish\Core\FieldType\DateAndTime\Value $value
  */
 public function fromHash($hash)
 {
     if ($hash === null) {
         return $this->getEmptyValue();
     }
     if (isset($hash['rfc850']) && $hash['rfc850']) {
         return Value::fromString($hash['rfc850']);
     }
     return Value::fromTimestamp((int) $hash['timestamp']);
 }
 /**
  * Data provider for valid input to acceptValue().
  *
  * Returns an array of data provider sets with 2 arguments: 1. The valid
  * input to acceptValue(), 2. The expected return value from acceptValue().
  * For example:
  *
  * <code>
  *  return array(
  *      array(
  *          null,
  *          null
  *      ),
  *      array(
  *          __FILE__,
  *          new BinaryFileValue( array(
  *              'path' => __FILE__,
  *              'fileName' => basename( __FILE__ ),
  *              'fileSize' => filesize( __FILE__ ),
  *              'downloadCount' => 0,
  *              'mimeType' => 'text/plain',
  *          ) )
  *      ),
  *      // ...
  *  );
  * </code>
  *
  * @return array
  */
 public function provideValidInputForAcceptValue()
 {
     return array(array(null, new DateAndTimeValue()), array('2012-08-28 12:20 Europe/Berlin', DateAndTimeValue::fromString('2012-08-28 12:20 Europe/Berlin')), array(1346149200, DateAndTimeValue::fromTimestamp(1346149200)), array($dateTime = new \DateTime(), new DateAndTimeValue($dateTime)));
 }