示例#1
0
 /**
  * @param Date $day
  * @return int
  */
 private function GetWeekNumber(Date $day)
 {
     $firstWeekday = $this->firstDay->Weekday();
     $week = floor($day->Day() / 7);
     if ($day->Day() % 7 == 0) {
         $week = ($day->Day() - 1) / 7;
         if ($day->Day() <= 7) {
             $week++;
         }
     } else {
         if ($day->Weekday() < $firstWeekday) {
             $week++;
         }
     }
     return intval($week);
 }
示例#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
 /**
  * @return int
  */
 public function DayOfMonth()
 {
     return $this->date->Day();
 }
示例#4
0
 /**
  * @param Date $date
  * @return string
  */
 public function GetDurationKey(Date $date)
 {
     return sprintf("%s%s%s", $date->Year(), $date->Month(), $date->Day());
 }
示例#5
0
 public function testJan31Bug()
 {
     $d = new Date('2013-01-31', 'America/Chicago');
     $this->assertEquals(31, $d->Day());
     $this->assertEquals(1, $d->Month());
     $this->assertEquals(2013, $d->Year());
 }
示例#6
0
 private function GetWeekNumber(Date $firstDate, $firstWeekdayOfMonth)
 {
     $week = ceil($firstDate->Day() / 7);
     return $week;
 }
示例#7
0
 /**
  * The current day midnight.
  * @return Date
  */
 static function Today()
 {
     $now = new Date();
     return new Date($now->Day(), $now->Month(), $now->Year(), 0, 0, 0);
 }