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 4018) - 28 March 2024

Legacy Cumulus 1 release v1.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

How To Change Date Format Of Last Rainfall

Discussion of Mark Crossley's HTML5/Javascript gauges

Moderator: mcrossley

Post Reply
Grimers
Posts: 240
Joined: Tue 24 Nov 2015 9:07 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 64-bit
Location: Newton Poppleford, Devon, UK
Contact:

How To Change Date Format Of Last Rainfall

Post by Grimers »

Hi Mark,

Once again, I've found another little thing I want to change. I've had a look at the script responsible but whenever I change parts of it I get random numbers or the date format in d-m-y. I want to change the Today and Yesterday as well as previous dates for the Last Rainfall date to d/m/y.

Is this possible?

Thanks!
User avatar
mcrossley
Posts: 12695
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: How To Change Date Format Of Last Rainfall

Post by mcrossley »

William, take a look in the Wiki... http://wiki.sandaysoft.com/a/Webtags#Li ... _modifiers
Edit: Note also the subtle differences between version 1 and MX.
Grimers
Posts: 240
Joined: Tue 24 Nov 2015 9:07 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 64-bit
Location: Newton Poppleford, Devon, UK
Contact:

Re: How To Change Date Format Of Last Rainfall

Post by Grimers »

Hi Mark,

I'm not sure I again worded this correctly, I am talking about the JS script gauges.js not web tags on Cumulus web pages. I tried changing the <#dateformat> style in the realtimegauges.txt file but it broke the gauges which was to be expected.

I presume this is the code I need to edit?

Code: Select all

try {
                    str = data.LastRainTipISO.split(' ');
                    dt = str[0].replace(/\//g, '-').split('-');  // WD uses dd/mm/yyyy, we use a '-'
                    tm = str[1].split(':');
                    today = new Date();
                    today.setHours(0, 0, 0, 0);
                    if (data.dateFormat === undefined) {
                        data.dateFormat = 'y/m/d';
                    } else {
                        // frig for WD bug which leaves a trailing % character from the tag
                        data.dateFormat = data.dateFormat.replace('%', '');
                    }
                    if (data.dateFormat === 'y/m/d') {
                        // ISO/Cumulus format
                        then = new Date(dt[0], dt[1] - 1, dt[2], tm[0], tm[1], 0, 0);
                    } else if (data.dateFormat === 'd/m/y') {
                        then = new Date(dt[2], dt[1] - 1, dt[0], tm[0], tm[1], 0, 0);
                    } else { // m/d/y
                        then = new Date(dt[2], dt[0] - 1, dt[1], tm[0], tm[1], 0, 0);
                    }
                    if (then.getTime() >= today.getTime()) {
                        data.LastRained = strings.LastRainedT_info + ' ' + str[1];
                    } else if (then.getTime() + 86400000 >= today.getTime()) {
                        data.LastRained = strings.LastRainedY_info + ' ' + str[1];
                    } else {
                        data.LastRained = then.getDate().toString() + ' ' + strings.months[then.getMonth()] + ' ' + strings.at + ' ' + str[1];
                    }
User avatar
mcrossley
Posts: 12695
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: How To Change Date Format Of Last Rainfall

Post by mcrossley »

If you just want a fixed format for the last rain, then you should be able to just comment out that whole block of try {} code. Then set the fixed format you want in the <#LastRainTipISO> tag.
Grimers
Posts: 240
Joined: Tue 24 Nov 2015 9:07 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 64-bit
Location: Newton Poppleford, Devon, UK
Contact:

Re: How To Change Date Format Of Last Rainfall

Post by Grimers »

mcrossley wrote:If you just want a fixed format for the last rain, then you should be able to just comment out that whole block of try {} code. Then set the fixed format you want in the <#LastRainTipISO> tag.
Ah, I thought so, the last time I did that, the gauges went belly up, probably took out too much code or left out some { }. Thanks, Mark!

Edit: No need to comment out code, just changed the format of the tag. :)
Post Reply