/Users/mgirouard/Sites/panda-php/trunk/Panda/Date.php

Go to the documentation of this file.
00001 <?php
00002 
00010 class Panda_Date
00011 {
00017     const DEFAULT_DATE = 'now';
00018 
00024     const DEFAULT_FORMAT = 'Y-m-d h:i:s';
00025 
00031     const MINUTE = 60;
00032 
00038     const HOUR = 3600;
00039 
00045     const DAY = 86400;
00046 
00052     const WEEK = 604800;
00053 
00059     const MONTH = 2629743.83;
00060 
00066     const YEAR = 31556926;
00067 
00073     private $timestamp;
00074 
00081     private $format;
00082 
00089     public function __construct($date = null, $format = null)
00090     {
00091         if (!$date) {
00092             $date = self::DEFAULT_DATE;
00093         }
00094 
00095         if (!$format) {
00096             $format = self::DEFAULT_FORMAT;
00097         }
00098 
00099         $this->timestamp = strtotime($date);
00100         $this->format = $format;
00101     }
00102 
00108     public function __toString()
00109     {
00110         return date($this->format, $this->timestamp);
00111     }
00112 
00119     public function set($date)
00120     {
00121         $this->timestamp = strtotime($date);
00122     }
00123 
00129     public function offset($offset)
00130     {
00131         $this->timestamp += (int) $offset;
00132     }
00133 
00140     public function setFormat($format)
00141     {
00142         $this->format = $format;
00143     }
00144 
00151     public function isLessThan($date)
00152     {
00153         return $this->timestamp < strtotime($date);
00154     }
00155 
00162     public function isGreaterThan($date)
00163     {
00164         return $this->timestamp > strtotime($date);
00165     }
00166 }

Generated on Thu Sep 4 01:56:50 2008 for Panda PHP Components by  doxygen 1.5.4