/** * */ static function AgeOfTrack($day_distance, $month_distance, $year_distance, $time_art) { /* * result of the age of the article ************************************************************ */ $config = JFactory::getConfig(); //$plural_hours_minArray = Array("/x/"); $plural_hours_minArray = array("/10 " . JText::_('TCE_PLG_DISTANCE_HOURS') . " " . JText::_('TCE_PLG_DISTANCE_AND') . "/", "/11 " . JText::_('TCE_PLG_DISTANCE_HOURS') . " " . JText::_('TCE_PLG_DISTANCE_AND') . "/", "/20 " . JText::_('TCE_PLG_DISTANCE_HOURS') . " " . JText::_('TCE_PLG_DISTANCE_AND') . "/", "/21 " . JText::_('TCE_PLG_DISTANCE_HOURS') . " " . JText::_('TCE_PLG_DISTANCE_AND') . "/", "/0 " . JText::_('TCE_PLG_DISTANCE_HOURS') . " " . JText::_('TCE_PLG_DISTANCE_AND') . "/", "/00 " . JText::_('TCE_PLG_DISTANCE_HOURS') . "/", "/1 " . JText::_('TCE_PLG_DISTANCE_HOURS') . " " . JText::_('TCE_PLG_DISTANCE_AND') . "/"); $plural_hours_min_replace_Array = array("10 " . JText::_('TCE_PLG_DISTANCE_HOURS'), "11 " . JText::_('TCE_PLG_DISTANCE_HOURS'), "20 " . JText::_('TCE_PLG_DISTANCE_HOURS'), "21 " . JText::_('TCE_PLG_DISTANCE_HOURS'), " ", " ", " " . JText::_('TCE_PLG_DISTANCE_ONEHOURS')); $plural_mon_yearArray = array("/10 " . JText::_('TCE_PLG_DISTANCE_YEARS') . " " . JText::_('TCE_PLG_DISTANCE_AND') . " 0 " . JText::_('TCE_PLG_DISTANCE_MONTHS') . "/", "/10 " . JText::_('TCE_PLG_DISTANCE_YEARS') . "/", "/11 " . JText::_('TCE_PLG_DISTANCE_YEARS') . " " . JText::_('TCE_PLG_DISTANCE_AND') . " 0 " . JText::_('TCE_PLG_DISTANCE_MONTHS') . "/", "/11 " . JText::_('TCE_PLG_DISTANCE_YEARS') . "/", "/1 " . JText::_('TCE_PLG_DISTANCE_YEARS') . "/", "/1 " . JText::_('TCE_PLG_DISTANCE_MONTHS') . "/"); $plural_mon_year_replace_Array = array("10 " . JText::_('TCE_PLG_DISTANCE_YEARS'), "11 " . JText::_('TCE_PLG_DISTANCE_YEARS'), "11 " . JText::_('TCE_PLG_DISTANCE_YEARS'), " " . JText::_('TCE_PLG_DISTANCE_ONEYEAR'), " " . JText::_('TCE_PLG_DISTANCE_ONEMONTH')); $start_time = strtotime($year_distance . "-" . $month_distance . "-" . $day_distance . " " . $time_art); /* * Date and time stamp with Timezone correction */ $start_time = $start_time + modLastPlayedHelper::TimezoneServer(); $current_time = modLastPlayedHelper::UtcTimestamp() + modLastPlayedHelper::TimezoneSetting(); //Current date and time stamp with UTC server correction $diff_time = $current_time - $start_time; if (modLastPlayedHelper::MonthsAndDaysCounter($day_distance, $month_distance, $year_distance, "months") <= 2 && modLastPlayedHelper::MonthsAndDaysCounter($day_distance, $month_distance, $year_distance, "days") >= 2) { return " " . modLastPlayedHelper::MonthsAndDaysCounter($day_distance, $month_distance, $year_distance, "days") . " " . JText::_('TCE_PLG_DISTANCE_DAYS'); } elseif (modLastPlayedHelper::MonthsAndDaysCounter($day_distance, $month_distance, $year_distance, "months") <= 2 && modLastPlayedHelper::MonthsAndDaysCounter($day_distance, $month_distance, $year_distance, "days") == 0 || modLastPlayedHelper::MonthsAndDaysCounter($day_distance, $month_distance, $year_distance, "days") == 1 && $diff_time <= 86400) { /* * diff_time = 60s = 1Mnin, and so on... * self day */ if ($diff_time <= 120) { return " " . JText::_('TCE_PLG_DISTANCE_ONEMINUTE'); } elseif ($diff_time >= 121) { $result_hour_min = floor($diff_time / 3600) . " " . JText::_('TCE_PLG_DISTANCE_HOURS') . " " . JText::_('TCE_PLG_DISTANCE_AND') . " " . floor($diff_time / 60 - floor($diff_time / 3600) * 60) . " " . JText::_('TCE_PLG_DISTANCE_MINUTES'); return $result_hour_min = preg_replace($plural_hours_minArray, $plural_hours_min_replace_Array, $result_hour_min); //ohne Korrektur //return $result_hour_min; } } elseif (modLastPlayedHelper::MonthsAndDaysCounter($day_distance, $month_distance, $year_distance, "months") <= 2 && modLastPlayedHelper::MonthsAndDaysCounter($day_distance, $month_distance, $year_distance, "days") == 1) { // Next 2 Days after article created $result_hour_min = " " . JText::_('TCE_PLG_DISTANCE_ONEDAY') . " " . JText::_('TCE_PLG_DISTANCE_AND') . " " . gmstrftime('%H ' . JText::_('TCE_PLG_DISTANCE_HOURS') . ' %M ' . JText::_('TCE_PLG_DISTANCE_MINUTES'), $diff_time); return $result_hour_min = preg_replace($plural_hours_minArray, $plural_hours_min_replace_Array, $result_hour_min); } elseif (modLastPlayedHelper::MonthsAndDaysCounter($day_distance, $month_distance, $year_distance, "months") == 12) { return " " . JText::_('TCE_PLG_DISTANCE_ONEYEAR'); } elseif (modLastPlayedHelper::MonthsAndDaysCounter($day_distance, $month_distance, $year_distance, "months") > 12) { $numbers_of_years = floor(modLastPlayedHelper::MonthsAndDaysCounter($day_distance, $month_distance, $year_distance, "months") / 12); //immer auf ganze Zahl abgerundet! $numbers_of_rest_month = modLastPlayedHelper::MonthsAndDaysCounter($day_distance, $month_distance, $year_distance, "months") - 12 * $numbers_of_years; //Berechnung der Restmonate zum vollem Jahr hin $result_mon_year = $numbers_of_years . " " . JText::_('TCE_PLG_DISTANCE_YEARS') . " " . JText::_('TCE_PLG_DISTANCE_AND') . " " . $numbers_of_rest_month . " " . JText::_('TCE_PLG_DISTANCE_MONTHS'); return $result_mon_year = preg_replace($plural_mon_yearArray, $plural_mon_year_replace_Array, $result_mon_year); } else { return " " . modLastPlayedHelper::MonthsAndDaysCounter($day_distance, $month_distance, $year_distance, "months") . " " . JText::_('TCE_PLG_DISTANCE_MONTHSAGO'); } }