un ajjout en reprenant le script "minMaxVal"
sauf que j'y met une recupération heure
la commande sera
minMaxDate($minOrMax, $_cmd_id, $start, $end,$dateFormat)
minOrMax = min/max
_cmd_id = la cmd
start = debut
end = fin
dateFormat = le format date
soit concretement
Code : Tout sélectionner
minMaxDate(max,#[Dehors][Sondes Nord][Température]#,yesterday,-1day23:59,d\ M\ à\ H:i)
et le resultat pour le max hier entre
2019-07-21 00:00
et
2019-07-21 23:59
Je vais évaluer : "21 Jul à 15:52"
Résultat : 21 Jul à 15:52
ou cumulé avec le max
Code : Tout sélectionner
str_replace('"', '',max(#[Dehors][Sondes Nord][Température]#,yesterday) minMaxDate(max,#[Dehors][Sondes Nord][Température]#,yesterday,-1day23:59,à\ H:i))
Je vais évaluer : "31.5 à 15:52"
Résultat : 31.5 à 15:52
Code : Tout sélectionner
public static function minMaxDate($minOrMax, $_cmd_id, $start, $end,$dateFormat) {
// minMaxDate(min,#[Dehors][Sondes Nord][Température]#,yesterday,-1day23:59)
date_default_timezone_set("Europe/Paris");
$startEval = date('Y-m-d H:i', ereg("[0-9]{4} [0-9]{4}", $start) ? DateTime::createFromFormat('md Hi', $start)->getTimestamp() : strtotime($start));
$endEval = date('Y-m-d H:i', ereg("[0-9]{4} [0-9]{4}", $end) ? DateTime::createFromFormat('md Hi', $end)->getTimestamp() : strtotime($end));
$cmdId = cmd::byString($_cmd_id)->getId();
$all = history::all($cmdId, $startEval, $endEval);
$ali = history::getStatistique($cmdId, $startEval, $endEval)[$minOrMax];
if(count($all) == 0) echo "Pas de valeurs sur la période donnée";
$current = $all[0];
$current = $all[0];
for ($i = 0; $i < count($all); $i++) {
$v = $all[$i];
if($minOrMax == "max" && $v->getValue() >= $current->getValue())
$current = $v;
if($minOrMax == "min" && $v->getValue() <= $current->getValue())
$current = $v;
}
return date ($dateFormat, strtotime($current->getDatetime()));
}