예제 #1
0
 public function getPreviousDate()
 {
     $date = $this->getDate();
     $startDate = $this->obj('StartDate');
     if ($date->format('Y') < $startDate->format('Y') || $date->format('n') < $startDate->format('n') || $date->format('j') <= $startDate->format('j')) {
         return;
     }
     $previousDate = new SS_DateTime('PreviousDate');
     $previousDate->setValue($date->getValue());
     do {
         $previousDate->setValue($previousDate->day_before($previousDate->format('Y'), $previousDate->format('n'), $previousDate->format('j')));
     } while ($previousDate->format('N') >= 6);
     // Skip past weekends.
     // If, after we skipped the weekend, we've shot past the start of sprint, then return.
     if ($previousDate->format('Y') < $startDate->format('Y') || $previousDate->format('n') < $startDate->format('n') || $previousDate->format('j') < $startDate->format('j')) {
         return;
     }
     return $previousDate;
 }