Blame view
sources/3rdparty/sabre/dav/lib/Sabre/DAV/Property/GetLastModified.php
1.67 KB
|
03e52840d
|
1 |
<?php |
|
6d9380f96
|
2 3 4 5 |
namespace Sabre\DAV\Property; use Sabre\DAV; use Sabre\HTTP; |
|
03e52840d
|
6 7 8 9 10 11 12 13 14 |
/**
* This property represents the {DAV:}getlastmodified property.
*
* Although this is normally a simple property, windows requires us to add
* some new attributes.
*
* This class uses unix timestamps internally, and converts them to RFC 1123 times for
* serialization
*
|
|
6d9380f96
|
15 16 17 |
* @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License |
|
03e52840d
|
18 |
*/ |
|
6d9380f96
|
19 |
class GetLastModified extends DAV\Property {
|
|
03e52840d
|
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
/**
* time
*
* @var int
*/
public $time;
/**
* __construct
*
* @param int|DateTime $time
*/
public function __construct($time) {
|
|
6d9380f96
|
34 |
if ($time instanceof \DateTime) {
|
|
03e52840d
|
35 36 |
$this->time = $time;
} elseif (is_int($time) || ctype_digit($time)) {
|
|
6d9380f96
|
37 |
$this->time = new \DateTime('@' . $time);
|
|
03e52840d
|
38 |
} else {
|
|
6d9380f96
|
39 |
$this->time = new \DateTime($time); |
|
03e52840d
|
40 41 42 |
}
// Setting timezone to UTC
|
|
6d9380f96
|
43 |
$this->time->setTimezone(new \DateTimeZone('UTC'));
|
|
03e52840d
|
44 45 46 47 48 49 |
}
/**
* serialize
*
|
|
6d9380f96
|
50 51 |
* @param DAV\Server $server
* @param \DOMElement $prop
|
|
03e52840d
|
52 53 |
* @return void
*/
|
|
6d9380f96
|
54 |
public function serialize(DAV\Server $server, \DOMElement $prop) {
|
|
03e52840d
|
55 56 57 58 |
$doc = $prop->ownerDocument;
//$prop->setAttribute('xmlns:b','urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/');
//$prop->setAttribute('b:dt','dateTime.rfc1123');
|
|
6d9380f96
|
59 |
$prop->nodeValue = HTTP\Util::toHTTPDate($this->time); |
|
03e52840d
|
60 61 62 63 64 65 |
}
/**
* getTime
*
|
|
6d9380f96
|
66 |
* @return \DateTime |
|
03e52840d
|
67 68 69 70 71 72 73 74 |
*/
public function getTime() {
return $this->time;
}
}
|