/**
  * Parse the input string and set our elements based on the contents of the
  * input string. Elements not found in the string will be null.
  * 
  * @return void
  * @access private
  * @since 5/24/05
  */
 function parse()
 {
     $term = trim(strtolower($this->input));
     if (in_array($term, $this->nowArray())) {
         $timespan = Timespan::current();
     } else {
         if (in_array($term, $this->todayArray())) {
             $timespan = Date::today();
         } else {
             if (in_array($term, $this->tomorrowArray())) {
                 $timespan = Date::tomorrow();
             } else {
                 if (in_array($term, $this->yesterdayArray())) {
                     $timespan = Date::yesterday();
                 }
             }
         }
     }
     $dateAndTime = $timespan->start();
     $offset = $dateAndTime->offset();
     $this->setYear($dateAndTime->year());
     $this->setMonth($dateAndTime->month());
     $this->setDay($dateAndTime->dayOfMonth());
     $this->setHour($dateAndTime->hour());
     $this->setMinute($dateAndTime->minute());
     $this->setSecond($dateAndTime->second());
     $this->setOffsetHour($offset->hours());
     $this->setOffsetMinute($offset->minutes());
     $this->setOffsetSecond($offset->seconds());
 }
Ejemplo n.º 2
0
 /**
  * Test the creation methods.
  */
 function test_creation()
 {
     // class methods - instance creation
     // current()
     // epoch()
     // starting()
     // startingDuration()
     // startingEnding()
     $timespan = Timespan::current();
     $this->assertEqual($timespan->startYear(), intval(date('Y')));
     $this->assertEqual($timespan->startMonth(), intval(date('n')));
     $this->assertEqual($timespan->dayOfMonth(), intval(date('j')));
     $duration = $timespan->duration();
     $this->assertTrue($duration->isEqualTo(Duration::zero()));
     $this->assertEqual(strtolower(get_class($timespan)), 'timespan');
     $timespan = Timespan::epoch();
     $this->assertEqual($timespan->startYear(), 1901);
     $this->assertEqual($timespan->startMonth(), 1);
     $this->assertEqual($timespan->dayOfMonth(), 1);
     $duration = $timespan->duration();
     $this->assertTrue($duration->isEqualTo(Duration::zero()));
     $this->assertEqual(strtolower(get_class($timespan)), 'timespan');
 }
Ejemplo n.º 3
0
 /**
  * Answer a new object that represents now.
  * 
  * @param optional string $class DO NOT USE OUTSIDE OF PACKAGE.
  *		This parameter is used to get around the limitations of not being
  *		able to find the class of the object that recieved the initial 
  *		method call.
  * @return object Month
  * @access public
  * @since 5/5/05
  * @static
  */
 static function current($class = 'Month')
 {
     $obj = parent::current($class);
     return $obj;
 }
Ejemplo n.º 4
0
 /**
  * Answer a new object that represents now.
  * 
  * @param optional string $class DO NOT USE OUTSIDE OF PACKAGE.
  *		This parameter is used to get around the limitations of not being
  *		able to find the class of the object that recieved the initial 
  *		method call.
  * @return object Schedule
  * @access public
  * @since 5/5/05
  * @static
  */
 static function current($class = 'Schedule')
 {
     $obj = parent::current($class);
     return $obj;
 }