예제 #1
0
파일: Date.php 프로젝트: hugutux/booked
 /**
  * @param Time $time
  * @param bool $isEndTime
  * @return Date
  */
 public function SetTime(Time $time, $isEndTime = false)
 {
     $date = Date::Create($this->Year(), $this->Month(), $this->Day(), $time->Hour(), $time->Minute(), $time->Second(), $this->Timezone());
     if ($isEndTime) {
         if ($time->Hour() == 0 && $time->Minute() == 0 && $time->Second() == 0) {
             return $date->AddDays(1);
         }
     }
     return $date;
 }
예제 #2
0
파일: Time.php 프로젝트: hugutux/booked
 /**
  * Compares this time to the one passed in
  * Returns:
  * -1 if this time is less than the passed in time
  * 0 if the times are equal
  * 1 if this time is greater than the passed in time
  * @param Time $time
  * @param Date|null $comparisonDate date to be used for time comparison
  * @return int comparison result
  */
 public function Compare(Time $time, $comparisonDate = null)
 {
     if ($comparisonDate != null) {
         $myDate = Date::Create($comparisonDate->Year(), $comparisonDate->Month(), $comparisonDate->Day(), $this->Hour(), $this->Minute(), $this->Second(), $this->Timezone());
         $otherDate = Date::Create($comparisonDate->Year(), $comparisonDate->Month(), $comparisonDate->Day(), $time->Hour(), $time->Minute(), $time->Second(), $time->Timezone());
         return $myDate->Compare($otherDate);
     }
     return $this->GetDate()->Compare($time->GetDate());
 }
예제 #3
0
 public function testCanCreateTimeInServerTimezone()
 {
     $hour = 10;
     $min = 22;
     $sec = 21;
     $time = new Time($hour, $min, $sec);
     $this->assertEquals("{$hour}:{$min}:{$sec}", $time->ToString());
     $this->assertEquals($hour, $time->Hour());
     $this->assertEquals($min, $time->Minute());
     $this->assertEquals($sec, $time->Second());
     $time = new Time($hour, $min);
     $this->assertEquals("{$hour}:{$min}:00", $time->ToString());
     $this->assertEquals($hour, $time->Hour());
     $this->assertEquals($min, $time->Minute());
     $this->assertEquals(0, $time->Second());
 }