Ejemplo n.º 1
0
 /**
  * Answer a new instance starting at midnight local time.
  * 
  * @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 TimeStamp
  * @access public
  * @since 5/3/05
  * @static
  */
 static function midnight($class = 'TimeStamp')
 {
     $obj = parent::midnight($class);
     return $obj;
 }
Ejemplo n.º 2
0
 /**
  * Test converting methods
  * 
  */
 function test_converting()
 {
     $time = Time::withHourMinuteSecond(15, 25, 10);
     // asDate ()
     $temp = $time->asDate();
     $this->assertTrue($temp->isEqualTo(Date::today()));
     $this->assertEqual(strtolower(get_class($temp)), 'date');
     // asDateAndTime ()
     $temp = $time->asDateAndTime();
     $comparison = DateAndTime::midnight();
     $comparison = $comparison->plus(Duration::withSeconds(55510));
     $this->assertTrue($temp->isEqualTo($comparison));
     $this->assertEqual(strtolower(get_class($temp)), 'dateandtime');
     // asDuration ()
     $temp = $time->asDuration();
     $this->assertTrue($temp->isEqualTo(Duration::withSeconds(55510)));
     $this->assertEqual(strtolower(get_class($temp)), 'duration');
     // asMonth ()
     $temp = $time->asMonth();
     $this->assertTrue($temp->isEqualTo(Month::starting(Date::today())));
     $this->assertEqual(strtolower(get_class($temp)), 'month');
     // asSeconds ()
     $this->assertEqual($time->asSeconds(), 55510);
     // asTime ()
     $temp = $time->asTime();
     $this->assertTrue($temp->isEqualTo($time));
     $this->assertEqual(strtolower(get_class($temp)), 'time');
     // asTimeStamp ()
     $temp = $time->asTimeStamp();
     $comparison = TimeStamp::midnight();
     $comparison = $comparison->plus(Duration::withSeconds(55510));
     $this->assertTrue($temp->isEqualTo($comparison));
     $this->assertEqual(strtolower(get_class($temp)), 'timestamp');
     // asWeek ()
     $temp = $time->asWeek();
     $this->assertTrue($temp->isEqualTo(Week::starting(Date::today())));
     $this->assertEqual(strtolower(get_class($temp)), 'week');
     // asYear ()
     $temp = $time->asYear();
     $this->assertTrue($temp->isEqualTo(Year::starting(Date::today())));
     $this->assertEqual(strtolower(get_class($temp)), 'year');
     // to ()
     $today = DateAndTime::today();
     $tomorrow = DateAndTime::tomorrow();
     $result = $time->to($tomorrow);
     $this->assertEqual(strtolower(get_class($result)), 'timespan');
     $this->assertTrue($result->isEqualTo(Timespan::startingDuration($today->plus(Duration::withSeconds(55510)), Duration::withDaysHoursMinutesSeconds(0, 8, 34, 50))));
     $result = $time->to(Time::withHourMinuteSecond(23, 25, 10));
     $this->assertEqual(strtolower(get_class($result)), 'timespan');
     $this->assertTrue($result->isEqualTo(Timespan::startingDuration($today->plus(Duration::withSeconds(55510)), Duration::withDaysHoursMinutesSeconds(0, 8, 0, 0))));
 }
Ejemplo n.º 3
0
 /**
  * Answer a new instance starting at midnight local time.
  * 
  * @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 StorableTime
  * @access public
  * @since 5/3/05
  * @static
  */
 static function midnight($class = 'StorableTime')
 {
     return parent::midnight($class);
 }