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


PHP Activity\Duration类代码示例

本文整理汇总了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());
         }
     }
 }
开发者ID:schoch,项目名称:Runalyze,代码行数:13,代码来源:class.ParserXMLpolarSingle.php

示例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();
 }
开发者ID:guancio,项目名称:Runalyze,代码行数:22,代码来源:StringReader.php

示例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>';
 }
开发者ID:n0rthface,项目名称:Runalyze,代码行数:37,代码来源:class.TableSwimLane.php

示例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;
 }
开发者ID:guancio,项目名称:Runalyze,代码行数:10,代码来源:Lap.php

示例5: 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

示例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('&nbsp;', ' ', implode(' / ', $laps));
 }
开发者ID:guancio,项目名称:Runalyze,代码行数:16,代码来源:Splits.php

示例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']) : '-';
     }
 }
开发者ID:rob-st,项目名称:Runalyze,代码行数:24,代码来源:class.TableZonesAbstract.php

示例8: 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

示例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);
开发者ID:n0rthface,项目名称:Runalyze,代码行数:31,代码来源:tpl.PaceTable.php

示例10: getTimeString

 /**
  * Get string for time
  * @return string
  */
 public function getTimeString()
 {
     return Duration::format($this->getTime());
 }
开发者ID:n0rthface,项目名称:Runalyze,代码行数:8,代码来源:class.Shoe.php

示例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));
 }
开发者ID:n0rthface,项目名称:Runalyze,代码行数:11,代码来源:Linker.php

示例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\'}">&Oslash; ' . Runalyze\Configuration::General()->distanceUnitSystem()->distanceUnit() . '</th>
					<th>&Oslash; ' . __('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);
    }
开发者ID:Nugman,项目名称:Runalyze,代码行数:50,代码来源:class.RunalyzePluginPanel_Equipment.php

示例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);
 }
开发者ID:guancio,项目名称:Runalyze,代码行数:17,代码来源:Duration.php

示例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);
 }
开发者ID:guancio,项目名称:Runalyze,代码行数:12,代码来源:Calculator.php

示例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>';
        }
    }
开发者ID:n0rthface,项目名称:Runalyze,代码行数:45,代码来源:class.RunalyzePluginStat_Rekorde.php


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