当前位置: 首页>>代码示例>>PHP>>正文


PHP Duration::format方法代码示例

本文整理汇总了PHP中Runalyze\Activity\Duration::format方法的典型用法代码示例。如果您正苦于以下问题:PHP Duration::format方法的具体用法?PHP Duration::format怎么用?PHP Duration::format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Runalyze\Activity\Duration的用法示例。


在下文中一共展示了Duration::format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: format

 /**
  * Format pace
  * @param int $secondsPerKm
  * @return string
  */
 public function format($secondsPerKm)
 {
     if ($secondsPerKm == 0) {
         return '-:--';
     }
     return Duration::format(round($secondsPerKm * $this->factorForUnit()));
 }
开发者ID:guancio,项目名称:Runalyze,代码行数:12,代码来源:AbstractTimeUnit.php

示例2: setDataToCode

 /**
  * Display data
  */
 protected function setDataToCode()
 {
     $this->Code .= '<table class="fullwidth zebra-style">';
     $this->Code .= '<thead><tr>';
     $this->Code .= '<th></th>';
     $this->Code .= '<th>' . __('Distance') . '</th>';
     $this->Code .= '<th>' . __('Time') . '</th>';
     $this->Code .= '<th>' . __('Swolf') . '</th>';
     $this->Code .= '<th>' . __('Strokes') . '</th>';
     $this->Code .= '<th>' . __('Type') . '</th>';
     $this->Code .= '</tr></thead>';
     $this->Code .= '<tbody>';
     $Loop = new Swimdata\Loop($this->Context->swimdata());
     $TrackLoop = new Trackdata\Loop($this->Context->trackdata());
     $Stroketype = new Stroketype(Stroketype::FREESTYLE);
     $Distance = new Distance(0);
     $max = $Loop->num();
     for ($i = 1; $i <= $max; ++$i) {
         $Stroketype->set($Loop->stroketype());
         $Distance->set($TrackLoop->distance());
         $this->Code .= '<tr class="r">';
         $this->Code .= '<td>' . $i . '.</td>';
         $this->Code .= '<td>' . $Distance->stringMeter() . '</td>';
         $this->Code .= '<td>' . Duration::format($TrackLoop->difference(Trackdata\Object::TIME)) . '</td>';
         $this->Code .= '<td>' . $Loop->swolf() . '</td>';
         $this->Code .= '<td>' . $Loop->stroke() . '</td>';
         $this->Code .= '<td>' . $Stroketype->shortstring() . '</td>';
         $this->Code .= '</tr>';
         $TrackLoop->nextStep();
         $Loop->nextStep();
     }
     $this->Code .= '</tbody>';
     $this->Code .= '</table>';
 }
开发者ID:n0rthface,项目名称:Runalyze,代码行数:37,代码来源:class.TableSwimLane.php

示例3: stringForActiveLaps

 /**
  * @param \Runalyze\Model\Activity\Splits\Entity $Splits
  * @return string
  * @codeCoverageIgnore
  */
 protected function stringForActiveLaps(Entity $Splits)
 {
     $laps = [];
     $onlyActiveSplits = $Splits->hasActiveAndInactiveLaps();
     foreach ($Splits->asArray() as $Split) {
         if (!$onlyActiveSplits || $Split->isActive()) {
             $laps[] = Activity\Duration::format($Split->time());
         }
     }
     return str_replace('&nbsp;', ' ', implode(' / ', $laps));
 }
开发者ID:guancio,项目名称:Runalyze,代码行数:16,代码来源:Splits.php

示例4: convertData

 /**
  * Convert data
  */
 private function convertData()
 {
     $totalTime = 0;
     $totalDist = 0;
     foreach ($this->Data as $Info) {
         $totalTime += $Info['time'];
         $totalDist += $Info['distance'];
     }
     foreach ($this->Data as $i => $Info) {
         if ($totalTime > 0) {
             $percentage = round(100 * $Info['time'] / $totalTime, 1);
         } elseif ($totalDist > 0) {
             $percentage = round(100 * $Info['distance'] / $totalDist, 1);
         } else {
             $percentage = '-';
         }
         $this->Data[$i]['percentage'] = $percentage;
         $this->Data[$i]['time'] = $totalTime > 0 ? Duration::format($Info['time']) : '-';
         $this->Data[$i]['distance'] = $totalDist > 0 ? Distance::format($Info['distance']) : '-';
     }
 }
开发者ID:rob-st,项目名称:Runalyze,代码行数:24,代码来源:class.TableZonesAbstract.php

示例5: getEquipmentTypeCode

    /**
     * @return string
     */
    protected function getEquipmentTypeCode()
    {
        $Code = '
			<table class="fullwidth zebra-style c">
				<thead>
					<tr>
						<th>' . __('Name') . '</th>
						<th>' . __('Type') . '</th>
						<th>' . __('max.') . Runalyze\Configuration::General()->distanceUnitSystem()->distanceUnit() . '</th>
						<th>' . __('max. Time') . '</th>
						<th>' . __('Sports') . '</th>
						<th>' . __('delete') . ' ' . $this->getDeleteIcon() . '</th>
					</tr>
				</thead>
				<tbody>';
        $Sports = $this->Model->allSports();
        $Types = $this->Model->allEquipmentTypes();
        $Types[] = new EquipmentType\Entity();
        foreach ($Types as $Type) {
            $isNew = !$Type->hasID();
            $id = $isNew ? -1 : $Type->id();
            $delete = $isNew ? '' : '<input type="checkbox" class="delete-checkbox" name="equipmenttype[delete][' . $id . ']">';
            $sportIDs = $isNew ? array() : $this->Model->sportForEquipmentType($id, true);
            $MaxDistance = new Distance($Type->maxDistance());
            $Code .= '
					<tr class="' . ($isNew ? ' unimportant' : '') . '">
						<td><input type="text" class="middle-size" name="equipmenttype[name][' . $id . ']" value="' . $Type->name() . '"></td>
						<td><select name="equipmenttype[input][' . $id . ']"">
								<option value="' . EquipmentType\Entity::CHOICE_SINGLE . '" ' . HTML::Selected(!$Type->allowsMultipleValues()) . '>' . __('Single choice') . '</option>
								<option value="' . EquipmentType\Entity::CHOICE_MULTIPLE . '" ' . HTML::Selected($Type->allowsMultipleValues()) . '>' . __('Multiple choice') . '</option>
							</select></td>
						<td><span class="input-with-unit"><input type="text" class="small-size" name="equipmenttype[max_km][' . $id . ']" value="' . round($MaxDistance->valueInPreferredUnit()) . '"><label class="input-unit">' . $MaxDistance->unit() . '</label></span></td>
						<td><input type="text" class="small-size" name="equipmenttype[max_time][' . $id . ']" value="' . ($Type->maxDuration() > 0 ? Duration::format($Type->maxDuration()) : '') . '" placeholder="d hh:mm:ss"></td>
						<td><input name="equipmenttype[sportid_old][' . $id . ']" type="hidden" value="' . implode(',', $sportIDs) . '">
							<select name="equipmenttype[sportid][' . $id . '][]" class="middle-size" multiple>';
            foreach ($Sports as $Sport) {
                $Code .= '<option value="' . $Sport->id() . '"' . HTML::Selected(in_array($Sport->id(), $sportIDs)) . '>' . $Sport->name() . '</option>';
            }
            $Code .= '</select></td>
						<td>' . $delete . '</td>
					</tr>';
        }
        $Code .= '
			</tbody>
		</table>';
        return $Code;
    }
开发者ID:guancio,项目名称:Runalyze,代码行数:50,代码来源:class.ConfigTabEquipment.php

示例6: displayPersonalBestYears

 /**
  * Display comparison for all years for personal bests
  */
 private function displayPersonalBestYears()
 {
     $year = array();
     $dists = array();
     $kms = is_array($this->Configuration()->value('pb_distances')) ? $this->Configuration()->value('pb_distances') : array(3, 5, 10, 21.1, 42.2);
     foreach ($kms as $km) {
         $dists[$km] = array('sum' => 0, 'pb' => INFINITY);
     }
     if ($this->RaceContainer->num() == 0) {
         return;
     }
     foreach ($this->RaceContainer->allRaces() as $wk) {
         $wk['y'] = date('Y', $wk['time']);
         if (!isset($year[$wk['y']])) {
             $year[$wk['y']] = $dists;
             $year[$wk['y']]['sum'] = 0;
             $year['sum'] = 0;
         }
         $year[$wk['y']]['sum']++;
         foreach ($kms as $km) {
             if ($km == $wk['distance']) {
                 $year[$wk['y']][$km]['sum']++;
                 if ($wk['s'] < $year[$wk['y']][$km]['pb']) {
                     $year[$wk['y']][$km]['pb'] = $wk['s'];
                 }
             }
         }
     }
     echo '<table class="fullwidth zebra-style">';
     echo '<thead>';
     echo '<tr>';
     echo '<th></th>';
     $Years = array_keys($year);
     sort($Years);
     foreach ($Years as $y) {
         if ($y != 'sum') {
             echo '<th>' . $y . '</th>';
         }
     }
     echo '</tr>';
     echo '</thead>';
     echo '<tbody>';
     PersonalBest::activateStaticCache();
     PersonalBest::lookupDistances($kms);
     foreach ($kms as $km) {
         echo '<tr class="r"><td class="b">' . (new Distance($km))->stringAuto(true, 1) . '</td>';
         foreach ($Years as $key) {
             $y = $year[$key];
             if ($key != 'sum') {
                 if ($y[$km]['sum'] != 0) {
                     $PB = new PersonalBest($km);
                     $distance = Duration::format($y[$km]['pb']);
                     if ($PB->seconds() == $y[$km]['pb']) {
                         $distance = '<strong>' . $distance . '</strong>';
                     }
                     echo '<td>' . $distance . ' <small>' . $y[$km]['sum'] . 'x</small></td>';
                 } else {
                     echo '<td><em><small>---</small></em></td>';
                 }
             }
         }
         echo '</tr>';
     }
     echo '<tr class="top-spacer no-zebra r">';
     echo '<td class="b">' . __('In total') . '</td>';
     foreach ($Years as $key) {
         if ($key != 'sum') {
             echo '<td>' . $year[$key]['sum'] . 'x</td>';
         }
     }
     echo '</tr>';
     echo '</tbody>';
     echo '</table>';
 }
开发者ID:rob-st,项目名称:Runalyze,代码行数:77,代码来源:class.RunalyzePluginStat_Wettkampf.php

示例7: displayData

 /**
  * Display the table with summed data for every month
  */
 private function displayData()
 {
     echo '<table class="analysis-table fullwidth zebra-style r">';
     echo '<thead>' . HTML::monthTr(8, 1) . '</thead>';
     echo '<tbody>';
     if (empty($this->KmData)) {
         echo '<tr><td colspan="13" class="c"><em>' . __('No activities found.') . '</em></td></tr>';
     }
     foreach ($this->KmData as $y => $Data) {
         echo '<tr><td class="b l">' . $y . '</td>';
         for ($m = 1; $m <= 12; $m++) {
             if (isset($Data[$m])) {
                 if ($this->dat == 'km') {
                     echo '<td title="' . Distance::format($Data[$m]['distance']) . '">' . Distance::format($Data[$m]['distance']) . $this->getCircleFor(100 * $Data[$m]['distance'] / $this->maxKm) . '</td>';
                     //echo '<td style="vertical-align: bottom;">' . $tooltip . $circle . '</td>';
                 } else {
                     if ($this->dat == 's') {
                         echo '<td title="' . $Data[$m]['s'] . '">' . Duration::format($Data[$m]['s']) . $this->getCircleFor(100 * $Data[$m]['s'] / $this->maxs) . '</td>';
                     } else {
                         if ($this->dat == 'em') {
                             echo '<td title="' . Elevation::format($Data[$m]['elevation']) . '">' . Elevation::format($Data[$m]['elevation']) . $this->getCircleFor(100 * $Data[$m]['elevation'] / $this->maxEm) . '</td>';
                         } else {
                             if ($this->dat == 'kcal') {
                                 echo '<td title="' . $Data[$m]['kcal'] . ' kcal">' . $Data[$m]['kcal'] . ' kcal' . $this->getCircleFor(100 * $Data[$m]['kcal'] / $this->maxKcal) . '</td>';
                             } else {
                                 if ($this->dat == 'trimp') {
                                     echo '<td title="' . $Data[$m]['trimp'] . '">' . $Data[$m]['trimp'] . $this->getCircleFor(100 * $Data[$m]['trimp'] / $this->maxTrimp) . '</td>';
                                 } else {
                                     if ($this->dat == 'n') {
                                         echo '<td title="' . $Data[$m]['n'] . '">' . $Data[$m]['n'] . $this->getCircleFor(100 * $Data[$m]['n'] / $this->maxN) . '</td>';
                                     }
                                 }
                             }
                         }
                     }
                 }
             } else {
                 echo HTML::emptyTD();
             }
         }
         echo '</tr>';
     }
     echo '</tbody></table>';
 }
开发者ID:rob-st,项目名称:Runalyze,代码行数:47,代码来源:class.RunalyzePluginStat_MonthlyStats.php

示例8: displayTDfor

 /**
  * Display td
  * @param int $num
  * @param int $time
  * @param float $dist
  * @param float $percent
  */
 private function displayTDfor($num, $time, $dist, $percent)
 {
     $tooltip = $num . 'x';
     $number = number_format($percent, 1) . ' &#37;';
     if ($this->dat == 'km') {
         $number = Distance::format($dist, false, 0);
         $tooltip .= ', ' . Duration::format($time);
     } elseif ($this->dat == 's') {
         $number = Duration::format($time);
     } else {
         $number = number_format($percent, 1) . ' &#37;';
         $tooltip .= ', ' . Duration::format($time);
     }
     echo '<td>' . Ajax::tooltip($number, $tooltip) . $this->getBarFor($percent) . '</td>';
 }
开发者ID:n0rthface,项目名称:Runalyze,代码行数:22,代码来源:class.RunalyzePluginStat_Analyse.php

示例9: elapsedTime

 /**
  * Get elapsed time
  * @return string
  */
 public function elapsedTime()
 {
     if ($this->Activity->elapsedTime() < $this->Activity->duration()) {
         return '-:--:--';
     }
     return Duration::format($this->Activity->elapsedTime());
 }
开发者ID:rob-st,项目名称:Runalyze,代码行数:11,代码来源:Dataview.php

示例10: showPrognosis

    /**
     * Show prognosis for a given distance
     * @param double $distance
     */
    protected function showPrognosis($distance)
    {
        $PB = new PersonalBest($distance);
        $PBTime = $PB->exists() ? Duration::format($PB->seconds()) : '-';
        $Prognosis = new Duration($this->Prognosis->inSeconds($distance));
        $Distance = new Distance($distance);
        $Pace = new Pace($Prognosis->seconds(), $distance, Pace::MIN_PER_KM);
        echo '<p>
				<span class="right">
					' . sprintf(__('<small>from</small> %s <small>to</small> <strong>%s</strong>'), $PBTime, $Prognosis->string(Duration::FORMAT_AUTO, 0)) . '
					<small>(' . $Pace->valueWithAppendix() . ')</small>
				</span>
				<strong>' . $Distance->string(Distance::FORMAT_AUTO, 1) . '</strong>
			</p>';
    }
开发者ID:n0rthface,项目名称:Runalyze,代码行数:19,代码来源:class.RunalyzePluginPanel_Prognose.php

示例11: parseTrackpoints

 /**
  * Parse all trackpoints for one lap
  * @param SimpleXMLElement $Lap
  */
 protected function parseTrackpoints(&$Lap)
 {
     $this->lastPoint = 0;
     foreach ($Lap->Track as $Track) {
         if ($this->lastPoint > 0) {
             $this->lastPointWasEmpty = true;
         }
         if (count($Track->xpath('./Trackpoint')) > 0) {
             $this->distancesAreEmpty = count($Track->xpath('./Trackpoint/DistanceMeters')) == 0;
             if (strtotime((string) $Lap['StartTime']) + 8 < strtotime((string) $Track->Trackpoint[0]->Time)) {
                 $this->lastPointWasEmpty = true;
             }
             foreach ($Track->Trackpoint as $Trackpoint) {
                 $this->parseTrackpoint($Trackpoint);
             }
         }
     }
     if (self::$DEBUG_SPLITS) {
         Error::getInstance()->addDebug('computed: ' . Duration::format(end($this->gps['time_in_s'])) . ', ' . Distance::format(end($this->gps['km'])));
     }
 }
开发者ID:rob-st,项目名称:Runalyze,代码行数:25,代码来源:class.ParserTCXSingle.php

示例12: showDataInTableView

 /**
  * Show data in table view
  * @param array $data
  * @param array $timeset
  */
 private function showDataInTableView($data, $timeset)
 {
     $Factory = new Factory(SessionAccountHandler::getId());
     if (empty($data)) {
         echo '<p><em>' . __('No data available.') . '</em></p>';
     } else {
         foreach ($data as $dat) {
             $Sport = $Factory->sport($dat['sportid']);
             $result = $dat['count_distance'] >= $dat['count'] / 2 ? Distance::format($dat['distance']) : Duration::format($dat['time_in_s']);
             echo '<p><span class="right"><small><small>(' . sprintf(__('%u-times'), Helper::Unknown($dat['count'], '0')) . ')</small></small> ' . $result . '</span> ';
             echo $Sport->icon()->code() . ' <strong>' . $Sport->name() . '</strong></p>';
         }
     }
     echo '<small class="right">' . __('since') . ' ' . date("d.m.Y", $timeset['start']) . '</small>';
     echo HTML::clearBreak();
 }
开发者ID:9x,项目名称:Runalyze,代码行数:21,代码来源:class.RunalyzePluginPanel_Sports.php

示例13: runCalculations

 /**
  * Init calculations
  */
 protected function runCalculations()
 {
     foreach ($this->Distances as $km) {
         $Prognosis = $this->PrognosisObject->inSeconds($km);
         $PB = new PersonalBest($km, DB::getInstance(), false);
         $PB->lookupWithDetails();
         $VDOTprognosis = new VDOT();
         $VDOTprognosis->fromPace($km, $Prognosis);
         $VDOTpb = new VDOT();
         $VDOTpb->fromPace($km, $PB->seconds());
         $PacePrognosis = new Pace($Prognosis, $km, Pace::MIN_PER_KM);
         $PacePB = new Pace($PB->seconds(), $km, Pace::MIN_PER_KM);
         $DateWithLink = Ajax::trainingLink($PB->activityId(), date('d.m.Y', $PB->timestamp()), true);
         $this->Prognoses[] = array('distance' => Distance::format($km, $km <= 3), 'prognosis' => Duration::format($Prognosis), 'prognosis-pace' => $PacePrognosis->valueWithAppendix(), 'prognosis-vdot' => $VDOTprognosis->uncorrectedValue(), 'diff' => !$PB->exists() ? '-' : ($PB->seconds() > $Prognosis ? '+ ' : '- ') . Duration::format(abs(round($PB->seconds() - $Prognosis))), 'diff-class' => $PB->seconds() > $Prognosis ? 'plus' : 'minus', 'pb' => $PB->seconds() > 0 ? Duration::format($PB->seconds()) : '-', 'pb-pace' => $PB->seconds() > 0 ? $PacePB->valueWithAppendix() : '-', 'pb-vdot' => $PB->seconds() > 0 ? $VDOTpb->uncorrectedValue() : '-', 'pb-date' => $PB->seconds() > 0 ? $DateWithLink : '-');
     }
 }
开发者ID:n0rthface,项目名称:Runalyze,代码行数:19,代码来源:class.Prognose_PrognosisWindow.php

示例14: foreach

		<?php 
    $Strategy->setVDOT($vdot);
    ?>
		<tr>
			<td class="b"><?php 
    echo $vdot;
    ?>
</td>
		<?php 
    foreach ($this->Configuration()->value('pace_distances') as $km) {
        ?>
		<?php 
        if ($km >= 1) {
            ?>
			<td><?php 
            echo Duration::format(round($Prognosis->inSeconds($km)));
            ?>
</td>
		<?php 
        }
        ?>
		<?php 
    }
    ?>
		</tr>
<?php 
}
?>
	</tbody>
</table>
开发者ID:guancio,项目名称:Runalyze,代码行数:30,代码来源:tpl.PrognosisTable.php

示例15: getFieldsetPaces

    /**
     * Get fieldset for paces
     * @return \FormularFieldset
     */
    public function getFieldsetPaces()
    {
        $Table = '<table class="fullwidth zebra-style">
				<thead>
					<tr>
						<th>' . __('Name') . '</th>
						<th class="small">' . __('Pace') . '</th>
						<th class="small">' . __('Description') . '</th>
					</tr>
				</thead>
				<tbody>';
        $VDOT = new VDOT(Configuration::Data()->vdot());
        foreach ($this->getArrayForPaces() as $Pace) {
            $Table .= '<tr>
						<td class="b">' . $Pace['short'] . '</td>
						<td class=""><em>' . Duration::format($VDOT->paceAt($Pace['limit-low'] / 100)) . '</em>&nbsp;-&nbsp;<em>' . Duration::format($VDOT->paceAt($Pace['limit-high'] / 100)) . '</em>/km</td>
						<td class="">' . $Pace['description'] . '</td>
					</tr>';
        }
        $Table .= '
				</tbody>
			</table>';
        $Fieldset = new FormularFieldset(__('Training paces'));
        $Fieldset->addBlock($Table);
        $Fieldset->addInfo(__('These paces are based on Jack Daniels\' recommendation.'));
        return $Fieldset;
    }
开发者ID:n0rthface,项目名称:Runalyze,代码行数:31,代码来源:class.RunalyzePluginPanel_Rechenspiele.php


注:本文中的Runalyze\Activity\Duration::format方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。