예제 #1
0
파일: Window.php 프로젝트: guancio/Runalyze
 /**
  * Read request
  */
 protected function readPropertiesFromRequest()
 {
     if ((double) Request::param('distance') > 0) {
         $this->LapDistance = min($this->Context->trackdata()->totalDistance(), (double) Request::param('distance'));
     }
     if (strlen(Request::param('time')) > 0) {
         $Time = new Duration(Request::param('time'));
         $this->LapTime = min($this->Context->trackdata()->totalTime(), $Time->seconds());
     }
     if (strlen(Request::param('demanded-time')) > 0) {
         $this->DemandedTime->fromString(Request::param('demanded-time'));
         if ($this->LapDistance > 0) {
             $this->DemandedPace->setTime($this->DemandedTime->seconds() / $this->LapDistance);
         }
     } elseif ($this->LapDistance > 0) {
         $this->DemandedTime->fromSeconds($this->Context->trackdata()->totalTime() / $this->Context->trackdata()->totalDistance() * $this->LapDistance);
         $this->DemandedPace->setTime($this->DemandedTime->seconds() / $this->LapDistance);
     }
     if (strlen(Request::param('demanded-pace')) > 0) {
         $this->DemandedPace->fromMinPerKm(Request::param('demanded-pace'));
         $this->DemandedTime->fromSeconds($this->LapDistance * $this->DemandedPace->secondsPerKm());
     } elseif ($this->DemandedPace->secondsPerKm() == 0) {
         $this->DemandedPace = $this->Context->dataview()->pace();
     }
     if (strlen(Request::param('manual-distances')) > 0) {
         $this->ManualDistances = Calculator::getDistancesFromString(Request::param('manual-distances'));
     }
     if (strlen(Request::param('manual-times')) > 0) {
         $this->ManualTimes = Calculator::getTimesFromString(Request::param('manual-times'));
     }
 }
예제 #2
0
 public function testTimesFromStringWithShortNotationForMinutes()
 {
     $this->assertEquals(array(5 * 60, 15 * 60, 20 * 60), Calculator::getTimesFromString('+5\', 10\', 5\''));
 }