openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

Date.class.php (1842B)


      1 <?php
      2 
      3 namespace dsl\standard;
      4 
      5 use dsl\context\BaseScriptableObject;
      6 
      7 
      8 /**
      9  * Date.
     10  *
     11  * Similar to the javascript Date object
     12  */
     13 class Date extends BaseScriptableObject
     14 {
     15 	private $time;
     16 
     17 	/**
     18 	 * @param integer $time unix timestamp
     19 	 */
     20 	public function __construct( $time = null )
     21 	{
     22 		if   ( $time == null )
     23 			$time = time();
     24 
     25 		$this->time = $time;
     26 	}
     27 
     28 
     29 	public function getDate()            { return date('d',$this->time); }
     30 	public function getDay()             { return date('w',$this->time); }
     31 	public function getFullYear()        { return date('Y',$this->time); }
     32 	public function getHours()           { return date('H',$this->time); }
     33 	public function getMilliseconds()    { return 0; }
     34 	public function getMinutes()         { return date('i',$this->time); }
     35 	public function getMonth()           { return date('m',$this->time); }
     36 	public function getSeconds()         { return date('s',$this->time); }
     37 	public function getTime()            { return $this->time * 1000; }
     38 	public function getTimezoneOffset()  { return date('y',$this->time)/60;}
     39 	public function getUTCDate()         { return date('d',$this->time);}
     40 	public function getUTCDay()          { return date('w',$this->time);}
     41 	public function getUTCFullYear()     { return date('Y',$this->time);}
     42 	public function getUTCHours()        { return date('H',$this->time);}
     43 	public function getUTCMilliseconds() { return 0;}
     44 	public function getUTCMinutes()      { return date('i',$this->time);}
     45 	public function getUTCMonth()        { return date('m',$this->time);}
     46 	public function getUTCSeconds()      { return date('s',$this->time);}
     47 	public function getYear()            { return date('y',$this->time); }
     48 
     49 	public function __toString()
     50 	{
     51 		return date('r');
     52 	}
     53 
     54 
     55 	/**
     56 	 * @return StandardString
     57 	 */
     58 	public function help()
     59 	{
     60 		return Helper::getHelp($this);
     61 	}
     62 }