Write the provided PHP DateTime object into a Kolab format UTC date-time
representation.
public static writeUtcDateTime ( DateTime $date_time ) : string | ||
$date_time | DateTime | The PHP DateTime object. |
return | string | The Kolab format UTC date-time string. |
/** * Generate the value that should be written to the node. Override in the * extending classes. * * @param string $name The name of the the attribute * to be updated. * @param array $attributes The data array that holds all * attribute values. * @param array $params The parameters for this write operation. * * @return mixed The value to be written. */ protected function generateWriteValue($name, $attributes, $params) { if (isset($attributes[$name])) { return Horde_Kolab_Format_Date::writeUtcDateTime($attributes[$name]); } else { return Horde_Kolab_Format_Date::writeUtcDateTime(new DateTime()); } }
/** * Generate the value that should be written to the node. Override in the * extending classes. * * @param string $name The name of the the attribute * to be updated. * @param array $attributes The data array that holds all * attribute values. * @param array $params The parameters for this write operation. * * @return mixed The value to be written. */ protected function generateWriteValue($name, $attributes, $params) { return Horde_Kolab_Format_Date::writeUtcDateTime(new DateTime('now', new DateTimeZone('UTC'))); }
/** * @dataProvider provideUtcExportDates */ public function testWriteUtc($string_date, $result) { $date = Horde_Kolab_Format_Date::readUtcDateTime($string_date); $this->assertEquals($result, Horde_Kolab_Format_Date::writeUtcDateTime($date)); }