aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/XMLRPCDateParameter.php
blob: 35e02fb37e1c76067132c9718ea19c7c04ce88bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/**
 * An ISO8601 data and time.
 *
 * @package    Elgg.Core
 * @subpackage XMLRPC
 */
class XMLRPCDateParameter extends XMLRPCParameter {
	/**
	 * Construct a date
	 *
	 * @param int $timestamp The unix timestamp, or blank for "now".
	 */
	function __construct($timestamp = 0) {
		parent::__construct();

		$this->value = $timestamp;

		if (!$timestamp) {
			$this->value = time();
		}
	}

	/**
	 * Convert to string
	 *
	 * @return string
	 */
	function __toString() {
		$value = date('c', $this->value);
		return "<value><dateTime.iso8601>{$value}</dateTime.iso8601></value>";
	}
}