Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Error dayswithnorain

Discussion of Ken True's web site templates

Moderator: saratogaWX

Post Reply
CarlosLSev
Posts: 20
Joined: Wed 03 Mar 2021 10:25 pm
Weather Station: Waldebeck Halley
Operating System: Raspberry Os

Error dayswithnorain

Post 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?
water01
Posts: 3246
Joined: Sat 13 Aug 2011 9:33 am
Weather Station: Ecowitt HP2551
Operating System: Windows 10 64bit
Location: Burnham-on-Sea
Contact:

Re: Error dayswithnorain

Post 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?
David
Image
CarlosLSev
Posts: 20
Joined: Wed 03 Mar 2021 10:25 pm
Weather Station: Waldebeck Halley
Operating System: Raspberry Os

Re: Error dayswithnorain

Post 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
water01
Posts: 3246
Joined: Sat 13 Aug 2011 9:33 am
Weather Station: Ecowitt HP2551
Operating System: Windows 10 64bit
Location: Burnham-on-Sea
Contact:

Re: Error dayswithnorain

Post by water01 »

This site seems to be based on Ken True's Saratoga Templates so I will move it to there.
David
Image
CarlosLSev
Posts: 20
Joined: Wed 03 Mar 2021 10:25 pm
Weather Station: Waldebeck Halley
Operating System: Raspberry Os

Re: Error dayswithnorain

Post 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?
CarlosLSev
Posts: 20
Joined: Wed 03 Mar 2021 10:25 pm
Weather Station: Waldebeck Halley
Operating System: Raspberry Os

Re: Error dayswithnorain

Post 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
Last edited by CarlosLSev on Mon 08 Apr 2024 9:43 pm, edited 1 time in total.
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Error dayswithnorain

Post 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.
water01
Posts: 3246
Joined: Sat 13 Aug 2011 9:33 am
Weather Station: Ecowitt HP2551
Operating System: Windows 10 64bit
Location: Burnham-on-Sea
Contact:

Re: Error dayswithnorain

Post 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
David
Image
Post Reply