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

Weather Console date format

Discussion and questions about Cumulus weather station software version 1. This section is the main place to get help with Cumulus 1 software developed by Steve Loft that ceased development in November 2014.
Post Reply
tmabell
Posts: 25
Joined: Sat 07 Mar 2015 12:25 am
Weather Station: Vantage Pro II
Operating System: Windows 7
Location: Indiana

Weather Console date format

Post by tmabell »

I'm using the Weather Console obtained from here: http://wiki.sandaysoft.com/index.php?ti ... herConsole

There is a function that displays the time of the last connection to the station as well as the time until the next poll. This is an example of what it looks like:
Last contact with station: 30/05/18 17:07:22. Update in: 8 seconds
My issue is the format of the date. I'd like it to be MM/DD/YY but as you can see the year is listed first. Can this be changed somehow?

Here is a screenshot:
https://mymishawakaweather.com/files/Untitled.jpg
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Weather Console date format

Post by beteljuice »

... MM/DD/YY but as you can see the year is listed first
err .. no it isn't :? DD is listed first ;)

If you really need to change it ...
That's from wsconsole.js

Code: Select all

$("#last_contact").html(rawdata[0] +" "+ rawdata[1]);
It is simply reading what is in realtime.txt (fields 0 and 1)

You would have to do some js coding to split and rearrange field[0] !
Image
......................Imagine, what you will KNOW tomorrow !
tmabell
Posts: 25
Joined: Sat 07 Mar 2015 12:25 am
Weather Station: Vantage Pro II
Operating System: Windows 7
Location: Indiana

Re: Weather Console date format

Post by tmabell »

Yes, sorry. Typo. So the wconsole.js is where I need to go?
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Weather Console date format

Post by beteljuice »

yes wconsole.js
You would need to change:

Code: Select all

$("#last_contact").html(rawdata[0] +" "+ rawdata[1]);
To something like:

Code: Select all

var thedate = rawdata[0].split('/'); // new array with date components (DD, MM, YY)
$("#last_contact").html(thedate[1] +"/"+ thedate[0] +"/"+ thedate[2] +" "+ rawdata[1]); // stitched to MM/DD/YY
UNTESTED !
Image
......................Imagine, what you will KNOW tomorrow !
tmabell
Posts: 25
Joined: Sat 07 Mar 2015 12:25 am
Weather Station: Vantage Pro II
Operating System: Windows 7
Location: Indiana

Re: Weather Console date format

Post by tmabell »

I tested your code and it works perfectly! Thanks a million :D
tmabell
Posts: 25
Joined: Sat 07 Mar 2015 12:25 am
Weather Station: Vantage Pro II
Operating System: Windows 7
Location: Indiana

Re: Weather Console date format

Post by tmabell »

Can the time format be changed from 24-hour to 12-hour in a similar manner?
tmabell
Posts: 25
Joined: Sat 07 Mar 2015 12:25 am
Weather Station: Vantage Pro II
Operating System: Windows 7
Location: Indiana

UPDATE Re: Weather Console date format

Post by tmabell »

I found a way to do this however, I can't find a way to remove the preceding zero when the hour is a single digit, i.e. 7:00 AM displays as 07:00 AM.

I replaced this:

Code: Select all

var d = new Date();
With this:

Code: Select all

var d = (h24 = new Date().getHours()) && (h24 - ((h24 == 0)? -12 : (h24 <= 12)? 0 : 12)) + (h24 < 12 ? " am" : " pm");
Last edited by tmabell on Fri 01 Jun 2018 1:29 pm, edited 1 time in total.
User avatar
mcrossley
Posts: 12694
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Weather Console date format

Post by mcrossley »

That will use the time from the client, not the time from the station. For the update time you could do something like this (untested)...

Code: Select all

var thedate = rawdata[0].split('/'); // new array with date components (DD, MM, YY)
var thetime = rawdata[1].split(':'); // new array with time components (hh, hh, ss)
thetime[0] = thetime[0] > 12 ? thetime[0] - 12 : thetime[0] * 1;
rawdata[1] = thetime.join(':');
$('#last_contact').html(thedate[1] +'/'+ thedate[0] +'/'+ thedate[2] +' '+ rawdata[1]); // stitched to MM/DD/YY
I leave it to you to do all the data times - I'd wrap that in a function and call it for each value.
tmabell
Posts: 25
Joined: Sat 07 Mar 2015 12:25 am
Weather Station: Vantage Pro II
Operating System: Windows 7
Location: Indiana

Re: Weather Console date format

Post by tmabell »

Mark,

Many thanks. Your code works right out of the box when inserted into wconsole.js.

However, there is no AM/PM appended to the time. Is this by design?

Tom

Note: Edited to remove an incorrect observation on my part.
User avatar
mcrossley
Posts: 12694
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Weather Console date format

Post by mcrossley »

Something like this then (untested again)...

Code: Select all

var thedate = rawdata[0].split('/'); // new array with date components (DD, MM, YY)
var thetime = rawdata[1].split(':'); // new array with time components (hh, hh, ss)
var amPm = thetime[0] > 12 ? 'pm' : 'am';
thetime[0] = thetime[0] > 12 ? 1 * thetime[0] - 12 : thetime[0] * 1;
rawdata[1] = thetime.join(':');
$('#last_contact').html(thedate[1] +'/'+ thedate[0] +'/'+ thedate[2] +' '+ rawdata[1]+ ' '+amPm); // stitched to MM/DD/YY
tmabell
Posts: 25
Joined: Sat 07 Mar 2015 12:25 am
Weather Station: Vantage Pro II
Operating System: Windows 7
Location: Indiana

Re: Weather Console date format

Post by tmabell »

Mark,

This version works! I will need to wait until after midnight here to determine if it works for hours that fall in the AM but so far so good.
Here is a sample output from my customization:
Last contact with station: 06/01/2018 at 1:32:30 pm. Next update in 18 seconds.
Thank you for your help.

Tom
Post Reply