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

Wrong time data in wxtrends.php

Discussion of Ken True's web site templates

Moderator: saratogaWX

Post Reply
Mark14
Posts: 79
Joined: Thu 23 Aug 2012 8:53 pm
Weather Station: Ecowitt HP3501
Operating System: Windows 10
Location: Konin, Poland

Wrong time data in wxtrends.php

Post by Mark14 »

Some time ago I had problem with time format but when I changed yyyy-MM-dd format into dd-MM-yyyy I thought that it was solved. I changed month and year data into into dd-MM-yyyy but still in http://pogodaslesin.byethost11.com/wxtr ... p?lang=en# in summary I have wrong data, eg.
Month 16.7 °C on 01-01-1970
.

This is a fragment of my month.ini file:

Code: Select all

[General]
Date=03-05-2013
[Wind]
Speed=15.5410175323486
SpTime=02-05-2013 12:18:15
Gust=24.480001449585
Time=03-05-2013 07:49:30
Windrun=215.178970336914
WindrunTime=03-05-2013 21:45:00
[Temp]
Low=7.30000019073486
LTime=02-05-2013 01:25:30
High=16.7000007629395
HTime=01-05-2013 15:53:35
LowMax=14.1000003814697
LMTime=02-05-2013 16:06:00
HighMin=8.10000038146973
HMTime=01-05-2013 05:24:00
LowRange=6.80000019073486
LowRangeTime=02-05-2013
HighRange=8.60000038146973
HighRangeTime=01-05-2013
I tried so long but I can't find the reason. Could you help me?
Image
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Wrong time data in wxtrends.php

Post by nitrx »

You are using Cumulus (1.9.2-b1032) maybe the time date tags don't work , you better upgrade to the latest stable version 1.9.3 . I'm not sure if this resolves the problem
Mark14
Posts: 79
Joined: Thu 23 Aug 2012 8:53 pm
Weather Station: Ecowitt HP3501
Operating System: Windows 10
Location: Konin, Poland

Re: Wrong time data in wxtrends.php

Post by Mark14 »

I updated Cumulus to 1.9.3-b1059 version and wxtrends for month and year are still wrong:
Month 19.7 °C on 01-01-1970
Year 26.0 °C on 01-01-1970
I don't understand this :roll:
Image
User avatar
saratogaWX
Posts: 1196
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: Wrong time data in wxtrends.php

Post by saratogaWX »

The record dates are wrong because you changed CU-defs.php to insert the month names in Polish and PHP does not understand dates in anything but English.

You have two instances in CU-defs.php that show

Code: Select all

  $EnglishMonths = array(
   "styczeń","luty","marzec","kwiecień","maj","czerwiec","lipiec","sierpień","wrzesień","paŸdziernik","listopad","grudzień");
Change that back to

Code: Select all

  $EnglishMonths = array(
   'January','February','March','April','May','June',
   'July','August','September','October','November','December');
for both instances and the dates should be processed correctly.

Alternatively, you can just upload the CU-defs.php from the CU-plugin.zip distribution .. it is not a file that should normally be changed.

Best regards,
Ken
Mark14
Posts: 79
Joined: Thu 23 Aug 2012 8:53 pm
Weather Station: Ecowitt HP3501
Operating System: Windows 10
Location: Konin, Poland

Re: Wrong time data in wxtrends.php

Post by Mark14 »

Yes, it was my fault with the translation of months. But now everything runs ok. Thank you one more time :)
Image
kapo
Posts: 246
Joined: Thu 03 Jan 2013 1:59 pm
Weather Station: Davis VP2
Operating System: Windows 10
Location: Vihtavuori, Laukaa, Finland

Re: Wrong time data in wxtrends.php

Post by kapo »

Hi
I get up this topic. My problem, which have solved once, occured again. So my wxcurrecords.php and wxtrends.php pages shows that 01.01.1970 at 02:00. And those dates come when the record is in month June, in finnish as "kesäkuu". I think could it be because that character ä is in month name and in wrong php folder? I looked my CUdefs.php and there month names are in english, but in CUtags.php, which Cumulus ftp, month names are in finnish. And our new temp record is in 2:nd "kesäkuu", which is shown as 01.01.1970. What is wrong, and how can I fix it? I know that it is my fault, but I hope that can fix in some way?

-kapo-
User avatar
saratogaWX
Posts: 1196
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: Wrong time data in wxtrends.php

Post by saratogaWX »

You seem to have Settings.php with

Code: Select all

$SITE['monthNames'] = array(  // for wxastronomy page .. replace with month names in your language 
'Tammikuu','Helmikuu','Maaliskuu','Huhtikuu','Toukokuu','Kesäkuu',
'Heinäkuu','Elokuu','Syyskuu','Lokakuu','Marraskuu','Joulukuu'
);

so the routine inside CU-defs.php

Code: Select all

#-------------------------------------------------------------------------------------
# CU support function - CU_getRecordDate - Convert 'dd Month '.'YYYY' to list(d,m,y)
#-------------------------------------------------------------------------------------

function CU_getRecordDate($inDayMonth,$inYear) {
  global $SITE,$Debug;
  
  $EnglishMonths = array(
   'January','February','March','April','May','June',
   'July','August','September','October','November','December');
   
  
  $tstr = $inDayMonth . ' ' . $inYear;
  $Debug .= "<!-- CU_getRecordDate input tstr='$tstr' -->\n";

 // input dates are assumed to be in English only
 if (isset($SITE['monthNames'])) {
    // convert TO English for strtotime()
	foreach ($EnglishMonths as $i => $monthEN) {
	   $tstr = preg_replace('|'.$SITE['monthNames'][$i].'|i',$monthEN,$tstr);
	}  
    $Debug .= "<!-- CU_getRecordDate after tstr='$tstr' -->\n";
  }

  $ttime = strtotime($tstr);
  $ltime = date('j n Y',$ttime);
  $Debug .= "<!-- CU_getRecordDate result ltime='$ltime' -->\n";
  return(explode(' ',$ltime));

}
should convert the dates to English for calculation as long as the $SITE['monthNames'] array is set to match the month names used in CUtags.php.

Doing a http://www.kapo511.net/wxtrends.php?debug=y then a view-source of the page shows
<!-- CU_getRecordDate input tstr='01 kesäkuu 2013' -->
<!-- CU_getRecordDate after tstr='01 kesäkuu 2013' -->
<!-- CU_getRecordDate result ltime='1 1 1970' -->
<!-- CU_getRecordDate input tstr='31 tammikuu 2013' -->
<!-- CU_getRecordDate after tstr='31 January 2013' -->
<!-- CU_getRecordDate result ltime='31 1 2013' -->
<!-- CU_getAlltimeDate input inDate='at 17:02 on 03 kesäkuu 2013' -->
<!-- CU_getAlltimeDate after tstr='03 kesäkuu 2013 17:02' -->
<!-- CU_getAlltimeDate result ltime='1 1 1970 02:00' -->
<!-- CU_getAlltimeDate input inDate='at 9:20 on 18 tammikuu 2013' -->
<!-- CU_getAlltimeDate after tstr='18 January 2013 9:20' -->
<!-- CU_getAlltimeDate result ltime='18 1 2013 09:20' -->
<!-- CU_getRecordDate input tstr='03 kesäkuu 2013' -->
<!-- CU_getRecordDate after tstr='03 kesäkuu 2013' -->
<!-- CU_getRecordDate result ltime='1 1 1970' -->
which shows it is working for the month 'tammikuu' (January), but not for the month 'kesäkuu' (June).

The only reasons I can think of that it is failing is either:

1) the Settings.php was not uploaded in ASCII using ISO-8859-1 character set so the 'ä' is not the correct code in the CU-tags.php uploaded by Cumulus

or

2) your Settings.php has the month name as 'Kes&auml;kuu' instead of 'Kesäkuu' (in ISO-8859-1).

Best regards,
Ken
kapo
Posts: 246
Joined: Thu 03 Jan 2013 1:59 pm
Weather Station: Davis VP2
Operating System: Windows 10
Location: Vihtavuori, Laukaa, Finland

Re: Wrong time data in wxtrends.php

Post by kapo »

Hi
And thanks again... The records date corrected after changing:" kes&auml;kuu" to: "kesäkuu" in wxsettings.php. I changed next month's name too, july, from: "hein&auml;kuu" to:"heinäkuu". There is only a little thing I wonder in my little mind... In wxsettings.php, there are a couple of words that has to be written with using that " &auml;" as: " Sääasema" , so how these month names has to be written in differend way? This is not a big thing, just ponder that... The main thing is that everything seems to work o.k. again. And thank You very much about that.


With best regards:

-kapo-
User avatar
saratogaWX
Posts: 1196
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: Wrong time data in wxtrends.php

Post by saratogaWX »

Hi Kapo,

Mostly, the text using national language characters (like 'ä') needs to be the native character code for that character set - so for Suomi/Finnish, it is in ISO-8859-1 . The HTML entity like &aumul; is processed by the browser to make a 'ä' display, but for PHP or JavaScript processing, the two representations are not equivalent. For the language translation feature to work with the templates, the text has to match exactly (binary match) so using HTML entities or a different character set will cause those matches to fail.

For items in Settings.php that are only for display on the page and not processed further by the language translation feature (like your city name), it is ok to use the HTML entitity in the name. I even do that with the names of the languages available so that the display will be correct regardless of what the current language/character set is used.

So.. always use the native character code first in the language-fi.txt/language-fi.js/Settings.php and resort to using the HTML entity only when the native character code cures a validation error (and does not break the translation feature).

Hope this helps...

Best regards,
Ken
kapo
Posts: 246
Joined: Thu 03 Jan 2013 1:59 pm
Weather Station: Davis VP2
Operating System: Windows 10
Location: Vihtavuori, Laukaa, Finland

Re: Wrong time data in wxtrends.php

Post by kapo »

Hi
Thank you for this very explanatory answer. And again, I think an old dog learns (at least I hope so) new tricks ...


All my best greetings from very sunny Finland, (approximately two weeks after we have couple of days that sun dosen't set down at all)



-kapo-
Post Reply