Page 1 of 1

Help with 24-hr difference

Posted: Fri 11 Feb 2022 8:46 pm
by josebp
Hi Ken,
i have changed ajax-dashboard.php - Version 1.30 and also Version CU-defs.php - V1.12 - 18-Jan-2022.
Everything seems to work fine but 24-hr difference is rounding the degrees and I only have differences of 0ºC, 1ºC, 2ºC...
I don't know why this rounding occurs.
I haven't found a way to fix it.
Thanks for your help.
Best Regards,
José Ramón
www.tiempoensevilla.es
----------------------------------------------------------------------
Hola Ken,
he cambiado ajax-dashboard.php - Version 1.30 y también la Version CU-defs.php - V1.12 - 18-Jan-2022.
Todo parece funcionar bien pero 24-hr difference está redondeando los grados y solamente tengo diferencias de 0ºC, 1ºC, 2ºC...
No sé por qué se produce ese redondeo.
No he encontrado la forma de arreglarlo.
Gracias por tu ayuda.
Saludos,
José Ramón
www.tiempoensevilla.es

Re: Help with 24-hr difference

Posted: Fri 11 Feb 2022 9:17 pm
by saratogaWX
The ajax-dashboard.php uses this code to display the 24hr difference

Code: Select all

                  <?php if(isset($temp24hoursago)) { ?>
                  <?php langtrans('24-hr difference'); ?>
				  <br />
                  <?php 
					if($commaDecimal) {
						$Tnow = preg_replace('|,|','.',strip_units($temperature));
						$TLast = preg_replace('|,|','.',strip_units($temp24hoursago)); 
					 } else {
						$Tnow = strip_units($temperature);
						$TLast = strip_units($temp24hoursago); 
					 }

					echo gen_difference($Tnow, $TLast, $uomTemp,
					langtransstr('Warmer'). ' %s'.$uomTemp.' '.langtransstr('than yesterday at this time').'.',
					langtransstr('Colder'). ' %s'.$uomTemp.' '.langtransstr('than yesterday at this time').'.'); ?>
                  <?php } // $temp24hoursago ?>
Looking at CU-tags.php?sce=dump on your site, shows

Code: Select all

$WX['RecentOutsideTemp h=24'] = '15,9';
so you are using comma-decimal notation.

For comma-decimal processing to be enabled with PHP, you need in Settings.php

Code: Select all

$SITE['commaDecimal'] = true;
and that is missing.

For AJAX, the ajaxCUwx.js JavaScript is already correct with

Code: Select all

var decimalComma = true;    // =false for '.' as decimal point, =true for ',' (comma) as decimal point
so the AJAX updated variables will be correct. The variables like $temp24hoursago need the entry in Settings.php to handle the comma-decimal format.

Re: Help with 24-hr difference

Posted: Sat 12 Feb 2022 9:59 am
by josebp
Thanks Ken.
But the decimal still does not come out in 24-hr difference
Best regards,
José Ramón

Re: Help with 24-hr difference

Posted: Sat 12 Feb 2022 6:13 pm
by saratogaWX
Yes, I see.

Change ajax-dashboard.php

Code: Select all

   if ($Legend) {
       return ($diff . $Legend . $image);
to

Code: Select all

   if ($Legend) {
       if($commaDecimal) { $diff = str_replace('.',',',(string)$diff); }
       return ($diff . $Legend . $image);

Re: Help with 24-hr difference

Posted: Sun 13 Feb 2022 7:09 am
by josebp
Thanks Ken.
but still the same
Best regards,
José Ramón