Esempio n. 1
0
 public function testMinPerKmComparison()
 {
     $Pace1 = new Pace(300, 1, PaceUnit::MIN_PER_KM);
     $Pace2 = new Pace(360, 1, PaceUnit::MIN_PER_KM);
     $Pace3 = new Pace(300, 1, PaceUnit::MIN_PER_KM);
     $Pace4 = new Pace(246, 1, PaceUnit::MIN_PER_KM);
     $this->assertEquals('+1:00', $Pace1->compareTo($Pace2, true));
     $this->assertEquals('+0:00', $Pace1->compareTo($Pace3, true));
     $this->assertEquals('-0:54', $Pace1->compareTo($Pace4, true));
 }
Esempio n. 2
0
    /**
     * Set halfs of competition
     */
    private function setHalfsOfCompetitionToCode()
    {
        if (empty($this->Halfs)) {
            return;
        }
        $this->Code .= '<tr class="no-zebra"><td colspan="5">&nbsp;</td></tr>';
        $this->Code .= '<tr class="b bottom-spacer no-zebra"><td colspan="5">' . __('1st/2nd Half') . '</td></tr>';
        $totalTime = 0;
        $totalDist = 0;
        foreach ($this->Halfs as $Half) {
            $totalTime += $Half['s'];
            $totalDist += $Half['km'];
        }
        $TotalPace = new Pace($totalTime, $totalDist, $this->PaceUnit);
        for ($i = 0, $num = count($this->Halfs); $i < $num; $i++) {
            $Pace = new Pace($this->Halfs[$i]['s'], $this->Halfs[$i]['km'], $this->PaceUnit);
            $this->Code .= '<tr class="r">
								<td></td>
								<td>' . Distance::format($this->Halfs[$i]['km'], true, 2) . '</td>
								<td>' . Duration::format($this->Halfs[$i]['s']) . '</td>
								<td>' . $Pace->valueWithAppendix() . '</td>
								<td>' . $Pace->compareTo($TotalPace) . '</td>
							</tr>';
        }
    }