Location: PHPKode > projects > PhpiCalLib > datetimeproperties.php
<?php
/**
 * datetimeproperties.php: iCalendar date-time property classes
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * @copyright Copyright (C) 2008 Nigel Swinson, hide@address.com 
 * @author  Nigel Swinson
 * @package PhpiCalLib
 * @version 1.0
 */

require_once 'unencodedproperties.php';

/**
 * Many properties specify a value of type date-time.  This base class can be used for those.
 *
 */
class PhpiCalLib_Properties_DateTimeProperty extends PhpiCalLib_Properties_UnencodedProperty {
	/**
	 * If {@link DataType} is PHPICALLIB_DATATYPE_DATE_TIME, this will be a {@link PhpiCalLib_DataType_DateTime} object.
	 *
	 * @var PhpiCalLib_DataType_DateTime
	 */
	private $DateTime = null;
	
	/**
	 * Constructor
	 */
	public function __construct() {
		parent::__construct();
		$this->DateTime = new PhpiCalLib_DataTypes_DateTime();
		// Start off with a date-time of the current time
		$this->DateTime->FromTimeStamp(time(), true);
		// Immediately sync the EncodedValue with the DateTime object
		$this->SetEncodedValue($this->DateTime->ToString());
	}
	
	/**
	 * Overridden to make sure that the value is a valid date-time token
	 *
	 * @param string $Value
	 */
	public function SetEncodedValue($Value) {
		$DateTime = new PhpiCalLib_DataTypes_DateTime();
		$DateTime->Parse($Value);
		// If we get here we didn't throw an exception, so the value is valid
		$this->DateTime = $DateTime;
		// Pass the value on to the parent
		parent::SetEncodedValue($Value);
	}
	
	/**
	 * Access the value as a DateTime
	 *
	 * @return PhpiCalLib_DateType_DateTime
	 */
	public function GetValue() {
		return $this->DateTime;
	}
	
	/**
	 * Set the value as a DateTime
	 *
	 * @param PhpiCalLib_DateType_DateTime $DateTime
	 */
	public function SetValue($DateTime) {
		parent::SetEncodedValue($DateTime->ToString());
		$this->DateTime = $DateTime;
	}
}

/**
 * The COMPLETED property.
 * <pre>
 *         completed  = "COMPLETED" compparam ":" date-time CRLF
 *         compparam  = *(";" other-param)
 * </pre>
 * @link http://tools.ietf.org/html/draft-ietf-calsify-rfc2445bis-08#section-3.8.2.1
 */
class PhpiCalLib_Properties_CompletedProperty extends PhpiCalLib_Properties_DateTimeProperty {
	public function __construct() {
		parent::__construct();
		$this->SetType(PHPICALLIB_PROPERTY_COMPLETED);
	}
}

/**
 * The CREATED property.
 * <pre>
 *         created    = "CREATED" creaparam ":" date-time CRLF
 *         creaparam  = *(";" other-param)
 * </pre>
 * @link http://tools.ietf.org/html/draft-ietf-calsify-rfc2445bis-08#section-3.8.7.1
 */
class PhpiCalLib_Properties_CreatedProperty extends PhpiCalLib_Properties_DateTimeProperty {
	public function __construct() {
		parent::__construct();
		$this->SetType(PHPICALLIB_PROPERTY_CREATED);
	}
}

/**
 * The DTSTAMP property.
 * <pre>
 *         dtstamp    = "DTSTAMP" stmparam ":" date-time CRLF
 *         stmparam   = *(";" other-param)
 * </pre>
 * @link http://tools.ietf.org/html/draft-ietf-calsify-rfc2445bis-08#section-3.8.7.2
 */
class PhpiCalLib_Properties_DtStampProperty extends PhpiCalLib_Properties_DateTimeProperty {
	public function __construct() {
		parent::__construct();
		$this->SetType(PHPICALLIB_PROPERTY_DTSTAMP);
	}
}

/**
 * The LAST-MODIFIED property.
 * <pre>
 *         last-mod   = "LAST-MODIFIED" lstparam ":" date-time CRLF
 *         lstparam   = *(";" other-param)
 * </pre>
 * @link http://tools.ietf.org/html/draft-ietf-calsify-rfc2445bis-08#section-3.8.7.3
 */
class PhpiCalLib_Properties_LastModifiedProperty extends PhpiCalLib_Properties_DateTimeProperty {
	public function __construct() {
		parent::__construct();
		$this->SetType(PHPICALLIB_PROPERTY_LASTMODIFIED);
	}
}
?>
Return current item: PhpiCalLib