Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Weather Console date format

Discussion and questions about Cumulus weather station software version 1. This section and its subforums are the main place to get help with Cumulus. Anything which is not specific to the type of weather station goes in here; for anything specific to a type of weather station, please use the appropriate subforum. Use the 'website development' section for any questions relating to creating or running a web site for Cumulus data. Discussion of the stations themselves in these sections is fine.
tmabell
Posts: 17
Joined: Sat Mar 07, 2015 12:25 am
Weather Station: Vantage Pro II
Operating System: Windows 7
Location: Indiana

Weather Console date format

Postby tmabell » Wed May 30, 2018 9:15 pm

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

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: 2469
Joined: Tue Dec 09, 2008 1:37 pm
Weather Station: None !
Operating System: XP SP3 - honest
Location: Dudley, West Midlands, UK

Re: Weather Console date format

Postby beteljuice » Wed May 30, 2018 11:28 pm

... 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: 17
Joined: Sat Mar 07, 2015 12:25 am
Weather Station: Vantage Pro II
Operating System: Windows 7
Location: Indiana

Re: Weather Console date format

Postby tmabell » Thu May 31, 2018 12:00 am

Yes, sorry. Typo. So the wconsole.js is where I need to go?

User avatar
beteljuice
Posts: 2469
Joined: Tue Dec 09, 2008 1:37 pm
Weather Station: None !
Operating System: XP SP3 - honest
Location: Dudley, West Midlands, UK

Re: Weather Console date format

Postby beteljuice » Thu May 31, 2018 1:43 am

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: 17
Joined: Sat Mar 07, 2015 12:25 am
Weather Station: Vantage Pro II
Operating System: Windows 7
Location: Indiana

Re: Weather Console date format

Postby tmabell » Thu May 31, 2018 11:28 am

I tested your code and it works perfectly! Thanks a million :D

tmabell
Posts: 17
Joined: Sat Mar 07, 2015 12:25 am
Weather Station: Vantage Pro II
Operating System: Windows 7
Location: Indiana

Re: Weather Console date format

Postby tmabell » Thu May 31, 2018 3:58 pm

Can the time format be changed from 24-hour to 12-hour in a similar manner?

tmabell
Posts: 17
Joined: Sat Mar 07, 2015 12:25 am
Weather Station: Vantage Pro II
Operating System: Windows 7
Location: Indiana

UPDATE Re: Weather Console date format

Postby tmabell » Fri Jun 01, 2018 12:10 pm

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 Jun 01, 2018 1:29 pm, edited 1 time in total.

User avatar
mcrossley
Posts: 5192
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Weather Console date format

Postby mcrossley » Fri Jun 01, 2018 12:27 pm

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: 17
Joined: Sat Mar 07, 2015 12:25 am
Weather Station: Vantage Pro II
Operating System: Windows 7
Location: Indiana

Re: Weather Console date format

Postby tmabell » Fri Jun 01, 2018 5:06 pm

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: 5192
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Weather Console date format

Postby mcrossley » Fri Jun 01, 2018 5:24 pm

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: 17
Joined: Sat Mar 07, 2015 12:25 am
Weather Station: Vantage Pro II
Operating System: Windows 7
Location: Indiana

Re: Weather Console date format

Postby tmabell » Fri Jun 01, 2018 5:33 pm

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


Return to “Cumulus 1”

Who is online

Users browsing this forum: No registered users and 6 guests