Page 1 of 1

Error dayswithnorain

Posted: Mon 01 Apr 2024 8:51 pm
by CarlosLSev
Hello, at the time I made a modification to the general board.
If it rains today it shows Today it rained, if it rained yesterday it shows Yesterday it rained, and if more than 1 day passes it shows It rained x days ago. The last day it rained was yesterday but it shows me that it rained today.
It's strange that this has been like this for a long time and it worked, I don't know if it's a Cumulus error or probably mine
The code is
if ($dayswithnorain == 0) {
echo langtrans('It rained today, ') . ' '. langtrans('at') . ' '. $timeoflastrainalways;
} elseif ($dayswithnorain == 1) {
echo langtrans('It rained yesterday ') . ' '. langtrans('at') . ' '. $timeoflastrainalways;
} elseif ($dayswithnorain > 1) {
echo $dayswithnorain . ' '. 'days since it rained' . ' at ' . $timeoflastrainalways . ' '. ' '. ' he '. $dateoflastrainalways;
}

I'm trying to locate where the variable $dayswithnorain is created

Can you help me with the error?

Re: Error dayswithnorain

Posted: Mon 01 Apr 2024 9:01 pm
by water01
$dayswithnorain usually means that this is a PHP webtag but there is no such webtag.

Could you let us no the web site address or give us an example of where the code is used so we can investigate further?

Re: Error dayswithnorain

Posted: Mon 01 Apr 2024 9:06 pm
by CarlosLSev
I have observed more websites and in all of them, even though the last rain was yesterday, the value is 0 instead of 1, before that was not the case, did anything change in any cumulusmx update?

yes www.meteoviso.es

Re: Error dayswithnorain

Posted: Mon 01 Apr 2024 9:17 pm
by water01
This site seems to be based on Ken True's Saratoga Templates so I will move it to there.

Re: Error dayswithnorain

Posted: Mon 01 Apr 2024 9:56 pm
by CarlosLSev
The variable is calculated within CU-defs.php
If today is day 01 month 4 year 2024 and it rained on day 31 month 3 year 2024, the value of dayswitnorain should be 1, and not 0 as indicated
if(substr($WX['LastRainTipISO'],0,4) <> '0000') { // got a valid date for the last rain
# $WX['LastRainTipISO'] = '2012-06-05 03:58';
$cuDF = ($SITE['WDdateMDY'])?'m/d/y':'d/m/y';
list($trainalwaysdate,$trainalwaystime) =
explode(' ',date("$cuDF H:i",strtotime($WX['LastRainTipISO'])));
$dayswithnorain = intval((strtotime(date('Y-m-d'))-strtotime(substr($WX['LastRainTipISO'],0,10)))/86400);
}
where this error?

Re: Error dayswithnorain

Posted: Tue 02 Apr 2024 9:30 pm
by CarlosLSev
Hello, after checking I can confirm that I believe it is due to an update of cumulusMX in version 3.28.4 - b3281
dayswithnorain behaved like this:
if there is rain today = 0
if it rained yesterday = 1
If it rained 2 or more days ago = 2
Since it is not the same
3.28.6 - b3283a
3.28.6 - b3283
3.28.5 - b3282
dayswithnorain
in these versions
is
If there is rain today =
I have to wait to verify this although it should be -1 , is 0
if it rained yesterday = 0
If it rained 2 or more days ago = 1
I have temporarily solved it like this

// Script que lee el fichero realtime
$realtime = "./realtime.txt";
$archivo = fopen($tiempo real, "r");
$linea=fgets($archivo);
fclose($archivo);
$dato ​​= explotar(" ", $linea);
$lluviahoyreal = isset($dato[9]) ? floatval($dato[9]) : 0;
$lluviaayerreal = isset($dato[21]) ? valor flotante($dato[21]) :0;

if ($lluviaayerreal == 0 && $lluviahoyreal == 0) {
$diassinlluvias= 1;
$diassinlluvia = $diassinlluvia + $diassinlluvias;
}

if ($diasconnorain == 0) {
echo langtrans('Hoy llovió, ') . '' . langtrans('a las') . '' . $timeoflastrainalways;
} elseif ($dayswithnorain == 1) {
echo langtrans('Ayer llovió ') . '' . langtrans('a las') . '' . $timeoflastrainalways;
} elseif ($díasconnorain > 1) {
echo $díasconnorain. '' . 'días desde que llovió' . ' Pobre de mí ' . $ timeoflastrainalways . '' . '' . 'el'. $ fechaoflastrainalways;
}
Modificar mensaje

Re: Error dayswithnorain

Posted: Tue 02 Apr 2024 10:30 pm
by mcrossley
If the original code (from above) was using the LastRainTipISO web tag...

Code: Select all

if(substr($WX['LastRainTipISO'], 0, 4) <> '0000') { // got a valid date for the last rain
    # $WX['LastRainTipISO'] = '2012-06-05 03:58';
    $cuDF = ($SITE['WDdateMDY']) ? 'm/d/y' : 'd/m/y';
    list($trainalwaysdate, $trainalwaystime) = explode(' ', date("$cuDF H:i", strtotime($WX['LastRainTipISO'])));
    $dayswithnorain = intval((strtotime(date('Y-m-d')) - strtotime(substr($WX['LastRainTipISO'], 0, 10))) / 86400);
}
Then I do not believe there has been any change in the presentation of that data in Cumulus MX, it has always been "YYYY-MM-DD hh:mm:ss"
Hello, after checking I can confirm that I believe it is due to an update of cumulusMX in version 3.28.4 - b3281
dayswithnorain behaved like this:
if there is rain today = 0
if it rained yesterday = 1
If it rained 2 or more days ago = 2
Since it is not the same
3.28.6 - b3283a
3.28.6 - b3283
3.28.5 - b3282
dayswithnorain
in these versions
is
If there is rain today =
I have to wait to verify this although it should be -1
if it rained yesterday = 0
If it rained 2 or more days ago = 1
The "dayswithnorain" variable has nothing to do with Cumulus MX, it looks like it is being calculated in your PHP code.

Re: Error dayswithnorain

Posted: Wed 03 Apr 2024 4:52 pm
by water01
The "dayswithnorain" variable has nothing to do with Cumulus MX, it looks like it is being calculated in your PHP code.
You need to check with Ken True who supplies the Saratoga PHP Template you are using, this is nothing to do with CumulusMX