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

Help with 24-hr difference

Discussion of Ken True's web site templates

Moderator: saratogaWX

Post Reply
josebp
Posts: 65
Joined: Tue 13 Apr 2010 11:37 am
Weather Station: Davis Vantage Pro2
Operating System: WINDOWS 10
Location: Sevilla, España
Contact:

Help with 24-hr difference

Post 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
Image
User avatar
saratogaWX
Posts: 1181
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Help with 24-hr difference

Post 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.
josebp
Posts: 65
Joined: Tue 13 Apr 2010 11:37 am
Weather Station: Davis Vantage Pro2
Operating System: WINDOWS 10
Location: Sevilla, España
Contact:

Re: Help with 24-hr difference

Post by josebp »

Thanks Ken.
But the decimal still does not come out in 24-hr difference
Best regards,
José Ramón
Image
User avatar
saratogaWX
Posts: 1181
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Help with 24-hr difference

Post 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);
josebp
Posts: 65
Joined: Tue 13 Apr 2010 11:37 am
Weather Station: Davis Vantage Pro2
Operating System: WINDOWS 10
Location: Sevilla, España
Contact:

Re: Help with 24-hr difference

Post by josebp »

Thanks Ken.
but still the same
Best regards,
José Ramón
Image
Post Reply