예제 #1
0
파일: TimeTest.php 프로젝트: 9x/Runalyze
 public function testDiffInDays()
 {
     $this->assertEquals(0, Time::diffInDays(mktime(0, 0, 0, 12, 5, 2000), mktime(0, 0, 0, 12, 5, 2000)));
     $this->assertEquals(0, Time::diffInDays(mktime(0, 0, 0, 12, 5, 2000), mktime(23, 59, 0, 12, 5, 2000)));
     $this->assertEquals(1, Time::diffInDays(mktime(0, 0, 0, 12, 5, 2000), mktime(0, 0, 0, 12, 6, 2000)));
     $this->assertEquals(5, Time::diffInDays(mktime(0, 0, 0, 12, 5, 2000), mktime(0, 0, 0, 12, 10, 2000)));
     $this->assertEquals(4, Time::diffInDays(mktime(17, 0, 0, 12, 5, 2000), mktime(15, 0, 0, 12, 10, 2000)));
     $this->assertEquals(5, Time::diffInDays(mktime(18, 0, 0, 12, 5, 2000), mktime(13, 0, 0, 12, 11, 2000)));
     $this->assertEquals(365, Time::diffInDays(mktime(0, 0, 0, 12, 5, 2000), mktime(0, 0, 0, 12, 5, 2001)));
 }
예제 #2
0
 /**
  * Check: Is this training too old for weather forecast?
  * @return boolean
  */
 private function trainingIsTooOldToFetchWeatherData()
 {
     return Time::diffInDays($this->getTimestamp()) > 30;
 }
예제 #3
0
			FROM `' . PREFIX . 'training`
			WHERE
				`time` BETWEEN UNIX_TIMESTAMP("' . $StartDay . '" + INTERVAL -' . $AddDays . ' DAY) AND UNIX_TIMESTAMP("' . $StartDay . '" + INTERVAL ' . $NumberOfDays . ' DAY)-1
			GROUP BY `index`')->fetchAll();
    //	Cache::set('calculationsPlotData'.$Year.$All.$lastHalf.$lastYear, $Data, '300');
    //}
    foreach ($Data as $dat) {
        $index = $dat['index'] + $AddDays;
        $Trimps_raw[$index] = 1 * $dat['trimp'];
        if ($dat['vdot'] != 0) {
            $VDOTs_raw[$index] = $dat['vdot'];
            // Remember: These values are already multiplied with `s`
            $Durations_raw[$index] = (double) $dat['s'];
        }
    }
    $StartDayInYear = $All || $lastHalf || $lastYear ? Time::diffInDays($StartTime, mktime(0, 0, 0, 1, 1, $StartYear)) + 1 : 0;
    $LowestIndex = $AddDays + 1;
    $HighestIndex = $AddDays + 1 + $NumberOfDays;
    $VDOTdays = Configuration::Vdot()->days();
    $ATLdays = Configuration::Trimp()->daysForATL();
    $CTLdays = Configuration::Trimp()->daysForCTL();
    $TSBModel = new Runalyze\Calculation\Performance\TSB($Trimps_raw, $CTLdays, $ATLdays);
    $TSBModel->calculate();
    if ($All) {
        $maxATL = $TSBModel->maxFatigue();
        $maxCTL = $TSBModel->maxFitness();
        if ($maxATL != Configuration::Data()->maxATL()) {
            Configuration::Data()->updateMaxATL($maxATL);
        }
        if ($maxCTL != Configuration::Data()->maxCTL()) {
            Configuration::Data()->updateMaxCTL($maxCTL);
 /**
  * Display the content
  * @see PluginPanel::displayContent()
  */
 protected function displayContent()
 {
     $this->showValues();
     if ($this->Configuration()->value('show_trainingpaces')) {
         $this->showPaces();
     }
     if (Time::diffInDays(START_TIME) < 70) {
         echo HTML::info(__('There are not enough activities for good calculations.'));
     }
 }
예제 #5
0
 /**
  * Get days used for week km for basic endurance
  * @return double 
  */
 public function getDaysForWeekKm()
 {
     $diff = Time::diffInDays(START_TIME);
     if ($diff > $this->DAYS_FOR_WEEK_KM) {
         return $this->DAYS_FOR_WEEK_KM;
     } elseif ($diff < $this->DAYS_FOR_WEEK_KM_MIN) {
         return $this->DAYS_FOR_WEEK_KM_MIN;
     }
     return $diff;
 }
예제 #6
0
    /**
     * Init all days for beeing displayed
     */
    protected function initDays()
    {
        $this->initShortSports();
        $this->initEmptyDays();
        $WhereNotPrivate = FrontendShared::$IS_SHOWN && !Configuration::Privacy()->showPrivateActivitiesInList() ? 'AND is_public=1' : '';
        $AllTrainings = $this->DB->query('
			SELECT
				id,
				time,
				`s` as `s_sum_with_distance`,
				DATE(FROM_UNIXTIME(time)) as `date`
				' . $this->Dataset->getQuerySelectForAllDatasets() . '
			FROM `' . PREFIX . 'training`
			WHERE `time` BETWEEN ' . ($this->timestamp_start - 10) . ' AND ' . ($this->timestamp_end - 10) . '
                        AND accountid = ' . SessionAccountHandler::getId() . '
				' . $WhereNotPrivate . '
			ORDER BY `time` ASC
		')->fetchAll();
        foreach ($AllTrainings as $Training) {
            $w = Time::diffInDays($Training['time'], $this->timestamp_start);
            if (in_array($Training['sportid'], $this->sports_short)) {
                $this->days[$w]['shorts'][] = $Training;
            } else {
                $this->days[$w]['trainings'][] = $Training;
            }
        }
    }