本文整理汇总了PHP中Runalyze\Activity\Duration类的典型用法代码示例。如果您正苦于以下问题:PHP Duration类的具体用法?PHP Duration怎么用?PHP Duration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Duration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseLaps
/**
* Parse laps
*/
protected function parseLaps()
{
if (isset($this->XML->result->laps)) {
foreach ($this->XML->result->laps->lap as $Lap) {
$distance = round((double) $Lap->distance / 1000, 2);
$Time = new Duration((string) $Lap->duration);
$this->TrainingObject->Splits()->addSplit($distance, $Time->seconds());
}
}
}
示例2: findDemandedPace
/**
* Find a pace goal within a string
*
* This method can be used to extract the demanded pace within a description,
* e.g. to find '3:20' within '6x1000m in 3:20, 400m pauses'.
* It will look for a time string directly after the given search pattern.
* The time string will be interpreted as time per kilometer.
*
* @param string $searchPattern [optional] String that must occur directly before the pace
* @return int Pace in s/km, 0 if nothing found
*/
public function findDemandedPace($searchPattern = ' in ')
{
$Lookup = explode($searchPattern, $this->String);
if (count($Lookup) < 2) {
return 0;
}
$cutPosition = strpos($Lookup[1], ' ');
$timeString = $cutPosition !== false ? substr($Lookup[1], 0, $cutPosition) : $Lookup[1];
$Duration = new Duration($timeString);
return $Duration->seconds();
}
示例3: 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>';
}
示例4: pace
/**
* @return \Runalyze\Activity\Pace
*/
public function pace()
{
if (null == $this->LapPace) {
$this->LapPace = new Pace($this->LapDuration->seconds(), $this->LapDistance->kilometer());
}
return $this->LapPace;
}
示例5: format
/**
* Format pace
* @param int $secondsPerKm
* @return string
*/
public function format($secondsPerKm)
{
if ($secondsPerKm == 0) {
return '-:--';
}
return Duration::format(round($secondsPerKm * $this->factorForUnit()));
}
示例6: 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(' ', ' ', implode(' / ', $laps));
}
示例7: 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']) : '-';
}
}
示例8: elapsedTime
/**
* Get elapsed time
* @return string
*/
public function elapsedTime()
{
if ($this->Activity->elapsedTime() < $this->Activity->duration()) {
return '-:--:--';
}
return Duration::format($this->Activity->elapsedTime());
}
示例9: Duration
<?php
use Runalyze\Activity\Duration;
use Runalyze\Activity\Distance;
$Duration = new Duration();
?>
<table id="jd-tables-prognosis" class="zebra-style r" style="width: 700px;">
<thead>
<tr>
<?php
foreach ($this->Configuration()->value('pace_distances') as $km) {
?>
<th><?php
echo Distance::format($km, $km <= 3, 1);
?>
</th>
<?php
}
?>
</tr>
</thead>
<tbody>
<?php
foreach ($this->Range as $sPer400m) {
?>
<tr>
<?php
foreach ($this->Configuration()->value('pace_distances') as $km) {
?>
<?php
$Duration->fromSeconds($km * $sPer400m / 0.4);
示例10: getTimeString
/**
* Get string for time
* @return string
*/
public function getTimeString()
{
return Duration::format($this->getTime());
}
示例11: linkWithSportIcon
/**
* Get link with icon as text
* @return string HTML-link to this training
*/
public function linkWithSportIcon()
{
$Sport = new Sport($this->Activity->sportid());
$Time = new Duration($this->Activity->duration());
$tooltip = $Sport->name() . ': ' . $Time->string();
return $this->link($Sport->Icon($tooltip));
}
示例12: displayTable
/**
* Display table
*/
public function displayTable()
{
if (is_null($this->Equipment)) {
$this->initTableData();
}
echo '<table id="list-of-all-equipment" class="fullwidth zebra-style">
<thead>
<tr>
<th class="{sorter: \'x\'} small">' . __('x-times') . '</th>
<th>' . __('Name') . '</th>
<th class="{sorter: \'germandate\'} small">' . __('since') . '</th>
<th class="{sorter: \'distance\'}">Ø ' . Runalyze\Configuration::General()->distanceUnitSystem()->distanceUnit() . '</th>
<th>Ø ' . __('Pace') . '</th>
<th class="{sorter: \'distance\'} small"><small>' . __('max.') . '</small> ' . Runalyze\Configuration::General()->distanceUnitSystem()->distanceUnit() . '</th>
<th class="small"><small>' . __('min.') . '</small> ' . __('Pace') . '</th>
<th class="{sorter: \'resulttime\'}">' . __('Time') . '</th>
<th class="{sorter: \'distance\'}">' . __('Distance') . '</th>
<th>' . __('Notes') . '</th>
</tr>
</thead>
<tbody>';
if (!empty($this->Equipment)) {
foreach ($this->Equipment as $data) {
$Object = new Model\Equipment\Object($data);
$in_use = $Object->isInUse() ? '' : ' unimportant';
$Pace = new Pace($Object->duration(), $Object->distance());
$MaxPace = new Pace($data['pace_in_s'], 1);
echo '<tr class="' . $in_use . ' r" style="position: relative">
<td class="small">' . $data['num'] . 'x</td>
<td class="b l">' . SearchLink::to('equipmentid', $Object->id(), $Object->name()) . '</td>
<td class="small">' . $this->formatData($Object->startDate()) . '</td>
<td>' . ($data['num'] != 0 ? Distance::format($Object->distance() / $data['num']) : '-') . '</td>
<td>' . ($Object->duration() > 0 ? $Pace->asMinPerKm() . '/km' : '-') . '</td>
<td class="small">' . Distance::format($data['dist']) . '</td>
<td class="small">' . $MaxPace->asMinPerKm() . '/km' . '</td>
<td>' . Duration::format($Object->duration()) . '</td>
<td>' . Distance::format($Object->totalDistance()) . '</td>
<td class="small">' . $Object->notes() . '</td>
</tr>';
}
} else {
echo '<tr><td colspan="9">' . __('You don\'t have any shoes') . '</td></tr>';
}
echo '</tbody>';
echo '</table>';
Ajax::createTablesorterFor("#list-of-all-equipment", true);
}
示例13: compareTo
/**
* Compare
* @param \Runalyze\Activity\Duration $other
* @param boolean $invert [optional] by default, larger is 'better'; set to true to invert that
* @param boolean $raw [optional]
* @throws \InvalidArgumentException
* @return string
*/
public function compareTo(Duration $other, $invert = false, $raw = false)
{
if ($this->seconds() == 0 || $other->seconds() == 0) {
return '';
}
$CompareTime = new Duration(round(abs($this->seconds() - $other->seconds())));
$isPositive = !$invert ? $this->seconds() > $other->seconds() : $this->seconds() <= $other->seconds();
return $this->formatComparison($CompareTime->string(), $isPositive, $raw);
}
示例14: explodeTimeStrings
/**
* @param string $commaSeparatedString
* @return array
*/
private static function explodeTimeStrings($commaSeparatedString)
{
$timeStrings = explode(',', $commaSeparatedString);
return array_map(function ($string) {
$Time = new Duration($string);
return $Time->seconds();
}, $timeStrings);
}
示例15: displayRekorde
/**
* Display the table with general records
*/
private function displayRekorde()
{
foreach ($this->rekorde as $rekord) {
echo '<table class="fullwidth zebra-style">';
echo '<thead><tr><th colspan="11" class="l">' . $rekord['name'] . '</th></tr></thead>';
echo '<tbody>';
$output = false;
$sports = DB::getInstance()->query($rekord['sportquery'])->fetchAll();
$Request = DB::getInstance()->prepare($rekord['datquery']);
foreach ($sports as $sport) {
$Request->bindValue('sportid', $sport['id']);
$Request->execute();
$data = $Request->fetchAll();
if (!empty($data)) {
$output = true;
echo '<tr class="r">';
echo '<td class="b l">' . Icon::getSportIconForGif($sport['img'], $sport['name']) . ' ' . $sport['name'] . '</td>';
$j = 0;
foreach ($data as $j => $dat) {
if ($rekord['speed']) {
$Pace = new Pace($dat['s'], $dat['distance'], SportFactory::getSpeedUnitFor($sport['id']));
$code = $Pace->valueWithAppendix();
} else {
$code = $dat['distance'] != 0 ? Distance::format($dat['distance']) : Duration::format($dat['s']);
}
echo '<td class="small"><span title="' . date("d.m.Y", $dat['time']) . '">
' . Ajax::trainingLink($dat['id'], $code) . '
</span></td>';
}
for (; $j < 9; $j++) {
echo HTML::emptyTD();
}
echo '</tr>';
}
}
if (!$output) {
echo '<tr><td colspan="11"><em>' . __('No data available') . '</em></td></tr>';
}
echo '</tbody>';
echo '</table>';
}
}