/** * @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); }
/** * 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()); }
/** * @return int */ public function DayOfMonth() { return $this->date->Day(); }
/** * @param Date $date * @return string */ public function GetDurationKey(Date $date) { return sprintf("%s%s%s", $date->Year(), $date->Month(), $date->Day()); }
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()); }
private function GetWeekNumber(Date $firstDate, $firstWeekdayOfMonth) { $week = ceil($firstDate->Day() / 7); return $week; }
/** * The current day midnight. * @return Date */ static function Today() { $now = new Date(); return new Date($now->Day(), $now->Month(), $now->Year(), 0, 0, 0); }