Author Topic: Re: Problems with Month and Year using Cumulus MX on Raspberry PI  (Read 3061 times)

Offline Andy9164

  • Full Member
  • ***
  • Posts: 87
    • Midlifedad
So unfortunately another very long email but hopefully it is worth it. I tested this on my WB2 template but I suspect it applies to all the templates that use formatting of date and times. This will correct the dates and times displayed on your website particularly in the This Month, This Year and All Time Records.

Changes to date time format in Cumulus MX

This applies to users of Cumulus MX only.
It does not affect those using Cumulus 1.x.x (e.g.  Version 1.9.4)

After a lot of research, trial and error and help from the Cumulus community (Steve and Mark) I finally managed to resolve the issues with the dates and times being displayed incorrectly in a Weather Blues V2_2b php template.

There were some changes made in Cumulus MX to the date and time formatting due to .NET being used as opposed to Delphi. From the Sandaysoft Wiki:

 â€œThe differences come about because Delphi is case-insensitive, and .Net is case sensitive, so .Net can use upper and lower case for different items, where Delphi has to use different letters.”

Details of the changes can be found here

http://wiki.sandaysoft.com/a/Webtag#Differences_for_Webtags_in_MX_builds

To highlight the changes I used the wt_data_inc.php file that comes with the Weather Blues V2_2b download available on this site as an example. Like me, you may have changed the basics of the file to provide different date formats or replace 12h00 with 12:00 for example so please do not use the examples below, they are there to show you what needs to be done.

The “This Month” and “This Year” pages under the History tab demonstrate the effect the best.

PLEASE ENSURE YOU MAKE A COPY OF YOUR OLD FILES BEFORE CHANGING

Changes in the wt_data_inc.php file located in your Cumulus MX installation (Not the version sent to your website)

Original File (Section - Monthly):

All the entries that look like this:

if (!is_numeric("<#MonthTempHD format='m'>")) $MonthTempHF = "<#MonthTempHD>"; else
$MonthTempHF = $pre_time.$MonthTempHT.$pre_date."<#MonthTempHD format='d'> ".$Tr_monthnames["<#MonthTempHD format='m'>"];

needs to be changed to this:

if (!is_numeric("<#MonthTempHD format="%M">")) $MonthTempHF = "<#MonthTempHD>"; else
$MonthTempHF = $pre_time.$MonthTempHT.$pre_date."<#MonthTempHD format="%d"> ".$Tr_monthnames["<#MonthTempHD format="%M">"];

Note:  You cannot use a single format selector on its own. It has to either be preceded with a % or have a space either before or after it. For example the previous selector  ‘m’ now needs to be  “%M” or  “ M” or “M “. You will also notice that the single quotation mark (‘) around the selector is replaced with a double quotation mark (“). For consistency and to highlight the fact that a single selector is being used I have always used a % in front of all of the single format selectors.

In the same file (Section - Annual):

All the entries that look like this:

if (!is_numeric("<#YearTempHD format='m'>")) $YearTempHF = $YearTempHD; else
$YearTempHF = $pre_time.$YearTempHT.$pre_date."<#YearTempHD format='d'> ".$Tr_monthnames["<#YearTempHD format='m'>"];;

needs to be changed to this:

if (!is_numeric("<#YearTempHD format="%M">")) $YearTempHF = $YearTempHD; else
$YearTempHF = $pre_time.$YearTempHT.$pre_date."<#YearTempHD format="%d"> ".$Tr_monthnames["<#YearTempHD format="%M">"];;

The time formats have also changed.

In the same file (Section – All Time Records):

All the entries that look like this:

$TtempHF = $pre_time.'<#TtempH format="h'h'nn">'.$pre_date.'<#TtempH format="d ">'.$Tr_monthnames['<#TtempH format="m">'].'<#TtempH format=" yyyy">';

need to be changed to this:

$TtempHF = $pre_time.'<#TtempH format="H'h'mm">'.$pre_date.'<#TtempH format="%d ">'.$Tr_monthnames['<#TtempH format="%M">'].'<#TtempH format=" yyyy">';

You will notice in the original file that the d already had a space following the letter d and the closing quotations. This was to allow a space between the date and the month i.e. 1 July.
For consistency I included a % before the d as per my notes above.

To change the file I used Notepad++ to highlight each section and then used “replace all”. It doesn’t take that long to do (10 minutes maximum).

If you also use the following files then I presume that these need to be changed as well.

wt_data_intl
wt_month_inc
wt_month_intl

I have attached  a copy of the initial modified file which shows all the changes. Its only there as an example and I wouldn’t use it directly but use it if you get stuck for reference. I have also included a copy of the above instructions so you can print them off to use when modifying the files.

If you want to see the standard wt_data_inc file working I have set up a standard WB-2 website here

http://www.midlifedad.me.uk/wb2_unmodified

If you want to see the modified wt_data_inc file working I have set up a modified WB-2 website here

http://www.midlifedad.me.uk/wb2_modified

I personally prefer 2 digit dates with a leading zero so “07 July” instead of “7 July” and the time format to be 23:10 instead of 23h10.

To change the date to 2 digits with a leading zero replace the “%d” with “dd” and for the time replace “H’h’mm” with either “H’:’mm” or “HH’:’mm” to get either 7:10 or 07:10

You can see the results on my website here. 

http://www.midlifedad.me.uk/weather

Any questions or comments than please feel free to ask. I am not perfect but have double checked everything several times so any problems please ask and I will try to help.

Andy
« Last Edit: July 13, 2015, 04:27:39 PM by Andy9164 »