本文整理汇总了PHP中Runalyze\Activity\Duration::seconds方法的典型用法代码示例。如果您正苦于以下问题:PHP Duration::seconds方法的具体用法?PHP Duration::seconds怎么用?PHP Duration::seconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Runalyze\Activity\Duration
的用法示例。
在下文中一共展示了Duration::seconds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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());
}
}
}
示例3: fromString
/**
* From string
* @param string $string
*/
public function fromString($string)
{
if (substr($string, 0, 1) == self::RESTING) {
$this->Active = false;
$string = substr($string, 1);
}
$Duration = new Duration(substr(strrchr($string, self::SEPARATOR), 1));
$this->Distance = rstrstr($string, self::SEPARATOR);
$this->Time = $Duration->seconds();
}
示例4: 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();
}
示例5: readPropertiesFromRequest
/**
* 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('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'));
}
}
示例6: validateTimeMinutes
/**
* Validator: time-string => time in minutes
* This will transform 6:23 to 6*60 + 23
* @param string $key
* @param array $options
* @return boolean
*/
protected static function validateTimeMinutes($key, $options)
{
$Time = new Duration($_POST[$key]);
$_POST[$key] = $Time->seconds();
if ($_POST[$key] == 0 && (isset($options['required']) || isset($options['notempty']))) {
return __('You have to enter a time.');
}
return true;
}
示例7: getWhere
/**
* Get where
* @return string
*/
protected function getWhere()
{
$conditions = array('`t`.`accountid`="' . $this->AccountID . '"');
if (isset($_POST['sportid'])) {
$this->addSportCondition($conditions);
}
if (isset($_POST['date-from']) && isset($_POST['date-to'])) {
$this->addTimeRangeCondition($conditions);
}
if (isset($_POST['s']) && strlen($_POST['s']) > 0) {
$Time = new Duration($_POST['s']);
$_POST['s'] = $Time->seconds();
}
foreach ($this->AllowedKeys as $key) {
if (isset($_POST[$key])) {
if (is_array($_POST[$key])) {
$this->addConditionForArray($key, $conditions);
} elseif (strlen($_POST[$key]) > 0) {
$this->addConditionFor($key, $conditions);
}
}
}
$this->addConditionsForOrder($conditions);
return $this->getEquipmentCondition() . $this->getTagCondition() . ' WHERE ' . implode(' AND ', $conditions);
}
示例8: 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>';
}
示例9: setupCameronStrategy
/**
* Setup prognosis strategy: David Cameron
*/
protected function setupCameronStrategy()
{
$Time = new Duration($_POST['best-result-time']);
$Strategy = new Prognosis\Cameron();
$Strategy->setReferenceResult($_POST['best-result-km'], $Time->seconds());
$this->PrognosisStrategies['david-cameron'] = $Strategy;
}
示例10: 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);
}
示例11: parsePostDataForEquipmentTypes
/**
* Parse post data for equipment types
*/
protected function parsePostDataForEquipmentTypes()
{
$DB = DB::getInstance();
$accountId = SessionAccountHandler::getId();
$Types = $this->Model->allEquipmentTypes();
$Types[] = new EquipmentType\Entity();
foreach ($Types as $Type) {
$isNew = !$Type->hasID();
$id = $isNew ? -1 : $Type->id();
$MaxTime = new Duration($_POST['equipmenttype']['max_time'][$id]);
$MaxDistance = new Distance();
$MaxDistance->setInPreferredUnit($_POST['equipmenttype']['max_km'][$id]);
$NewType = clone $Type;
$NewType->set(EquipmentType\Entity::NAME, $_POST['equipmenttype']['name'][$id]);
$NewType->set(EquipmentType\Entity::INPUT, (int) $_POST['equipmenttype']['input'][$id]);
$NewType->set(EquipmentType\Entity::MAX_KM, $MaxDistance->kilometer());
$NewType->set(EquipmentType\Entity::MAX_TIME, $MaxTime->seconds());
if ($isNew) {
if ($NewType->name() != '') {
$Inserter = new EquipmentType\Inserter($DB, $NewType);
$Inserter->setAccountID($accountId);
$Inserter->insert();
$RelationUpdater = new EquipmentType\RelationUpdater($DB, $Inserter->insertedID());
$RelationUpdater->update($_POST['equipmenttype']['sportid'][$id]);
}
} elseif (isset($_POST['equipmenttype']['delete'][$id])) {
$DB->deleteByID('equipment_type', (int) $id);
} else {
$Updater = new EquipmentType\Updater($DB, $NewType, $Type);
$Updater->setAccountID($accountId);
$Updater->update();
$RelationUpdater = new EquipmentType\RelationUpdater($DB, $Type->id());
$RelationUpdater->update($_POST['equipmenttype']['sportid'][$id], explode(',', $_POST['equipmenttype']['sportid_old'][$id]));
}
}
$this->Model->clearCache('equipment_type');
}
示例12: 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);
}
示例13: fillFromArray
/**
* Set empty times from array
* @param array $Time
* @param array $Distance
* @param string $mode
*/
protected function fillFromArray(array $Time, array $Distance, $mode = 'time')
{
$totalDistance = 0;
$totalTime = 0;
$size = min(count($Time), count($Distance));
$i = 0;
foreach ($this->asArray as &$split) {
if ($mode == 'km') {
$Duration = new Duration($split['time']);
while ($i < $size - 1 && $Duration->seconds() > $Time[$i] - $totalTime) {
$i++;
}
$split['km'] = $this->formatKM($Distance[$i] - $totalDistance);
} else {
while ($i < $size - 1 && $split['km'] > $Distance[$i] - $totalDistance) {
$i++;
}
$split['time'] = $this->formatTime($Time[$i] - $totalTime);
}
$totalTime = $Time[$i];
$totalDistance = $Distance[$i];
}
$this->arrayToString();
}
示例14: showPrognosis
/**
* Show prognosis for a given distance
* @param double $distance
*/
protected function showPrognosis($distance)
{
$PB = new PersonalBest($distance);
$PB->lookupWithDetails();
$PBTime = $PB->exists() ? Duration::format($PB->seconds()) : '-';
$PBString = $PB->exists() ? Ajax::trainingLink($PB->activityId(), $PBTime, true) : $PBTime;
$Prognosis = new Duration($this->Prognosis->inSeconds($distance));
$Distance = new Distance($distance);
$Pace = new Pace($Prognosis->seconds(), $distance, SportFactory::getSpeedUnitFor(Configuration::General()->runningSport()));
echo '<p>
<span class="right">
' . sprintf(__('<small>from</small> %s <small>to</small> <strong>%s</strong>'), $PBString, $Prognosis->string(Duration::FORMAT_AUTO, 0)) . '
<small>(' . $Pace->valueWithAppendix() . ')</small>
</span>
<strong>' . $Distance->stringAuto(true, 1) . '</strong>
</p>';
}
示例15: readLap
/**
* Read lap
*/
private function readLap()
{
if (strpos($this->Line, ':')) {
$Time = new Duration(substr($this->Line, 0, 10));
$this->TrainingObject->Splits()->addSplit(0, $Time->seconds() - $this->totalSplitsTime);
$this->totalSplitsTime = $Time->seconds();
}
}