<?php

if(!class_exists('DateTimeZone'))
{
	/**
	 * DateTimeZone 
	 *
	 * This class represents a timezone.
	 * This is a very mimimal replacement of PHP 5.2+'s DateTimeZone.
	 *
	 * @package Sabre
	 * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
	 * @author Evert Pot (http://www.rooftopsolutions.nl/) 
	 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
	 */
	class DateTimeZone {
	
	    /**
	     * Timezone string
	     * 
	     * @var string 
	     */
	    protected $timezone;
	
	    /**
	     * __construct 
	     * 
	     * @param string $timezoneStr 
	     */
	    public function __construct($timezoneStr) {
	
	        $this->timezone = $timezoneStr;
	
	    }
	
	    /**
	     * Returns the timezone name 
	     * 
	     * @return string
	     */
	    public function getName() {
	
	        return $this->timezone;
	
	    }
	    
	    /**
	     * Returns the offset of the timezone
	     * 
	     * @return int
	     */
	    public function getOffset() {
			$oldTz = date_default_timezone_get();
			$offset = 0;
			
			try
			{
				date_default_timezone_set($this->timezone);
				$offset = date('Z');
			}
			catch(Exception $e)
			{
				$offset = 0;
			}
			
			date_default_timezone_set($oldTz);
			return $offset;
	
	    }
	}
}

?>
