Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class date extends obj

Helix obj date
Hide Inherited MembersCalendar
Description
No description.
 
Constants
No constants.
 
Properties
protected_day[ date ]
protected_dirty[ obj ]
protected_hour[ date ]
protected_minute[ date ]
protected_month[ date ]
publicproperty_objects_array[ obj ]
protected_second[ date ]
protected_utime[ date ]
protected_year[ date ]
 
Methods
public__construct ( datetime , hour , minute , second , month , day , year )[ date ]
Parameters
optionaldatetime
optionalhour
optionalminute
optionalsecond
optionalmonth
optionalday
optionalyear
Code
012  public function __construct($__datetime=null, $__hour=null, $__minute=null, $__second=null, $__month=null, $__day=null, $__year=null)
013  {
014      if (is_null($__hour) && is_null($__minute) && is_null($__second) && is_null($__month) && is_null($__day) && is_null($__year))
015      {
016          $datetime = is_array($__datetime) ? $__datetime : date_parse(is_null($__datetime) ? date("Y-m-d") : $__datetime);
017          $this->_hour = keyval($datetime,"hour");
018          $this->_minute = keyval($datetime,"minute");
019          $this->_second = keyval($datetime,"second");
020          $this->_month = keyval($datetime,"month");
021          $this->_day = keyval($datetime,"day");
022          $this->_year = keyval($datetime,"year");
023      }
024      else
025      {
026          $this->_hour = $__hour;
027          $this->_minute = $__minute;
028          $this->_second = $__second;
029          $this->_month = $__month;
030          $this->_day = $__day;
031          $this->_year = $__year;
032      }
033 
034  }
publicformat ( format )[ date ]
Parameters
optionalformat
Code
046  public function format($format=null)
047  {
048      if ($this->valid)
049      {
050          if (is_null($format) || preg_match("/us/i",$format))
051          {
052              return date("m/d/Y",$this->get_utime());
053          }
054          else
055          {
056              return date(is_null($format) ? "Y-m-d H:i:s" : $format,$this->get_utime());
057          }
058      }
059      else
060      {
061          return null;
062      }
063  }
public__get ( p )[ obj ]
Parameters
requiredp
Code
007  public function __get($p)
008  {
009      $methods = get_class_methods($this);
010      $properties = get_object_vars($this);
011      if (in_array("get_$p",$methods))
012      {
013          return $this->{"get_$p"}();
014      }
015      else if (array_key_exists("_$p",$properties))
016      {
017          return $this->{"_$p"};
018      }
019      else if (in_array("get_" . substr($p,strpos($p,"_")+1), $methods))
020      {
021          return $this->{"get_" . substr($p,strpos($p,"_")+1)}(substr($p,0,strpos($p,"_")));
022      }
023      else
024      {
025          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
026          return null;
027      }
028  }
publicget_array ( )[ obj ]
Parameters
No parameters for this method
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicget_classname ( )[ obj ]
Parameters
No parameters for this method
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publicget_dirty ( )[ obj ]
Parameters
No parameters for this method
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicget_json ( )[ obj ]
Parameters
No parameters for this method
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicget_string ( )[ date ]
Parameters
No parameters for this method
Code
070  public function get_string()
071  {
072      return $this->__toString();
073  }
publicget_time ( )[ date ]
Parameters
No parameters for this method
Code
080  public function get_time()
081  {
082      return date("H:i:s",$this->get_utime());
083  }
publicget_utime ( )[ date ]
Parameters
No parameters for this method
Code
075  public function get_utime()
076  {
077      return mktime($this->_hour,$this->_minute,$this->_second,$this->_month,$this->_day,$this->_year);
078  }
publicget_valid ( )[ date ]
Parameters
No parameters for this method
Code
065  public function get_valid()
066  {
067      return ($this->_hour>0 || $this->_minute>0 || $this->_second>0 || $this->_month>0 || $this->_day>0 || $this->_year>0);
068  }
public staticmonth_abbreviations ( )[ date ]
Parameters
No parameters for this method
Code
103  public static function month_abbreviations()
104  {
105      return array(
106          "jan",
107          "feb",
108          "mar",
109          "apr",
110          "may",
111          "jun",
112          "jul",
113          "aug",
114          "sep",
115          "oct",
116          "nov",
117          "dec"
118      );
119  }
public staticmonth_names ( )[ date ]
Parameters
No parameters for this method
Code
085  public static function month_names()
086  {
087      return array(
088          "january",
089          "february",
090          "march",
091          "april",
092          "may",
093          "june",
094          "july",
095          "august",
096          "september",
097          "october",
098          "november",
099          "december"
100      );
101  }
public staticnow ( )[ date ]
Parameters
No parameters for this method
Code
041  public static function now()
042  {
043      return new date("Y-m-d H:i:s");
044  }
public__set ( p , v )[ obj ]
Parameters
requiredp
requiredv
Code
030  public function __set($p,$v)
031  {
032      $methods = get_class_methods($this);
033      $properties = get_object_vars($this);
034      if (in_array("set_$p",$methods))
035      {
036          $this->{"set_$p"}($v);
037      }
038      else if (array_key_exists("_$p",$properties))
039      {
040          if (!preg_match('/_dirty$/',$p) && property_exists($this,"_{$p}_dirty"))
041          {
042              if (is_object($this->{"_$p"}))
043              {
044                  $this->{"_$p"}->dirty = true;
045              }
046              else
047              {
048                  $this->{"_{$p}_dirty"} = $this->{$p}==$v ? false : true;
049              }
050          }
051          $this->{"_$p"} = $v;
052      }
053      else if (in_array("set_" . substr($p,strpos($p,"_")+1), $methods))
054      {
055          $this->{"set_" . substr($p,strpos($p,"_")+1)}($v,substr($p,0,strpos($p,"_")));
056      }
057      else
058      {
059          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
060      }
061  }
public__toString ( )[ date ]
Parameters
No parameters for this method
Code
036  public function __toString()
037  {
038      return $this->format();
039  }
public staticweek_abbreviations ( )[ date ]
Parameters
No parameters for this method
Code
134  public static function week_abbreviations()
135  {
136      return array(
137          "sun",
138          "mon",
139          "tues",
140          "wed",
141          "thurs",
142          "fri",
143          "sat"
144      );
145  }
public staticweek_names ( )[ date ]
Parameters
No parameters for this method
Code
121  public static function week_names()
122  {
123      return array(
124          "sunday",
125          "monday",
126          "tuesday",
127          "wednesday",
128          "thursday",
129          "friday",
130          "saturday"
131      );
132  }
 
Accessors
publicarray[ obj ]
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicclassname[ obj ]
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publicdirty[ obj ]
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicjson[ obj ]
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicstring[ date ]
Code
070  public function get_string()
071  {
072      return $this->__toString();
073  }
publictime[ date ]
Code
080  public function get_time()
081  {
082      return date("H:i:s",$this->get_utime());
083  }
publicutime[ date ]
Code
075  public function get_utime()
076  {
077      return mktime($this->_hour,$this->_minute,$this->_second,$this->_month,$this->_day,$this->_year);
078  }
publicvalid[ date ]
Code
065  public function get_valid()
066  {
067      return ($this->_hour>0 || $this->_minute>0 || $this->_second>0 || $this->_month>0 || $this->_day>0 || $this->_year>0);
068  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads