1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8class Search_Type_DateTime implements Search_Type_Interface
9{
10	private $value;
11
12	function __construct($value, $dateOnly = false)
13	{
14		if (is_numeric($value)) {
15			if ($dateOnly) {
16				// dates are stored as formatted strings in Tiki timezone to prevent date shifts when timezones differ
17				$oldTz = date_default_timezone_get();
18				date_default_timezone_set(TikiLib::lib('tiki')->get_display_timezone());
19				$this->value = date('Y-m-d', $value);
20				date_default_timezone_set($oldTz);
21			} else {
22				// dates with times are stored in GMT
23				$this->value = gmdate(DateTime::W3C, $value);
24			}
25		}
26	}
27
28	function getValue()
29	{
30		return $this->value;
31	}
32}
33