LONTE SHELL EDITION


Dashboard -*- SHOW INFO -*- HASH identify -*- Config -*- Jumping

You Are Here : /var/www/virtual/tvarditsa.org/classes/
Upload File :
Current File : /var/www/virtual/tvarditsa.org/classes/timer.class.php

<?php // _$_ timer.class.php _ timer _ version 1.0 _ valio _$_ //
if (!defined("_TIMER_CLASS_")) {
define("_TIMER_CLASS_", 1);

// ---  Configuration   --- //

/* no config */

// -  Auto Include Parent - //

if (!defined("_DATETIME_CLASS_")) {
  $this_directory = dirname(__FILE__) . DIRECTORY_SEPARATOR;
  include ($this_directory . 'datetime.class.php');
}

// --  Class Definition  -- //

  class Timer extends DateTime {

// ----  Private Vars  ---- //

    var $_timers;

// ----  Constructor   ---- //

    function Timer ($lang = "bg", $cfg = null) {
      $this->__construct($lang, $cfg);
    }

    function __construct($lang = "bg", $cfg = null) {
      DateTime::__construct($lang, $cfg);
    }

// ---  Public Methods  --- //

    function start () {
      if (sizeof ($this->_timers) > 0) {
        ksort ($this->_timers);
        end($this->_timers);
        $id = key($this->_timers) + 1;
        $this->_timers[$id] = new DateTime ();
        $timer = & $this->_timers[$id];
        $timer->set_now();
        return $id;
      } else {
        $this->_timers = array();
        $this->_timers[1] = new DateTime ();
        $timer = & $this->_timers[1];
        $timer->set_now();
        return 1;
      }
    }

    function stop ($id) {
      if (isset($this->_timers[$id])) {
        $timer_now = new DateTime ();
        $timer_now->set_now();
        $timer_val = $timer_now->diff($this->_timers[$id]);
        unset ($this->_timers[$id]);
        return $timer_val;
      } else return 0;
    }

// --  Private Methods   -- //

// -----  Destructor  ----- //

	function __destruct() {
      DateTime::__destruct();
	}

  }

} // END TIMER_CLASS
?>