Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 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

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

Request for new webtag - days Cumulus has been running

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.
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Request for new webtag - days Cumulus has been running

Post by RayProudfoot »

Hi Steve,

I would like to display the number of days Cumulus has been running. At present we have the tag <#recordsbegandate> which should be the date Cumulus started and <#date> which is today's date.

Would it be much work to deduct one from the other and present the answer as a new tag?

Thanks.
Cheers,
Ray, Cheshire.

Image
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Request for new webtag - days Cumulus has been running

Post by steve »

No, that wouldn't be too hard; I could probably add it in 1.9.4 at some point. Very easy to do with javascript, of course, as Mark suggested in the recent thread about days since 1899:

var daysSince1899 = (new Date() - new Date(1899, 11, 30)) / (24 * 60 * 60 * 1000);

Just put your start date in instead of 30/11/1899.
Steve
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Request for new webtag - days Cumulus has been running

Post by RayProudfoot »

My knowledge of Javascript is less than nothing but I'm sure there will be a tutorial out there I can learn from.

Thanks Steve.
Cheers,
Ray, Cheshire.

Image
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Request for new webtag - days Cumulus has been running

Post by RayProudfoot »

I've got this far but can't work out how to display only the integer part.

<!DOCTYPE html>
<html>
<body>

<script>
var CumulusRunDays=(new Date() - new Date(2009, 05, 10)) / (24 * 60 * 60 * 1000);
document.write(CumulusRunDays);
</script>
</body>
</html>

I'm sure it's very simple. :)
Cheers,
Ray, Cheshire.

Image
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Request for new webtag - days Cumulus has been running

Post by RayProudfoot »

Adding this line seems to have done the trick...

CumulusRunDays=parseInt(CumulusRunDays)

I shall continue this tommorow.
Cheers,
Ray, Cheshire.

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

Re: Request for new webtag - days Cumulus has been running

Post by mcrossley »

That will do it Ray, or use Math.floor() as the value is already a number.

parseInt() is really for string to number conversion, and it is good practice to specify the base (xxx,10) when using parseInt() - numbers with leading zeros will be converted to octal without it.
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Request for new webtag - days Cumulus has been running

Post by RayProudfoot »

Thank you Mark. This is how the code looks now.

<!DOCTYPE html>
<html>
<body>

<script>
var CumulusRunDays=(new Date() - new Date(2009, 04, 10)) / (24 * 60 * 60 * 1000);
CumulusRunDays=Math.floor(CumulusRunDays)-1

document.write(CumulusRunDays);
</script>
</body>
</html>

I saw on one website that the month of the starting date has a base value of 0 so 1 should be deducted from it for the correct number of days to be calculated. Then 1 day has to be deducted to arrive at the correct number of days.

Tomorrow I will embed this into my HTML page.
Cheers,
Ray, Cheshire.

Image
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Request for new webtag - days Cumulus has been running

Post by steve »

Ray, I know you're having fun with javascript and all that, and I don't want to spoil it, but Arthur has found a serious bug in the realtime.txt code for (some) people with 'extra' sensors. I was hoping not to do another build of 1.9.3, but I have to fix this bug, and as your web tag is only five lines of code, I'll sneak that in too.
Steve
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Request for new webtag - days Cumulus has been running

Post by RayProudfoot »

That's nice of you Steve, thanks. :)

I have made good progress and may well complete it just so I can say I've dipped my toe into Javascript.
Cheers,
Ray, Cheshire.

Image
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Request for new webtag - days Cumulus has been running

Post by RayProudfoot »

I've completed my first attempt at Javascript and you can see the result on my home page just below the links to other webpages. http://www.cheadlehulmeweather.co.uk

I'd appreciate any advice on how I've written the code and whether it conforms to Javascript standards.

Steve, I'll also include the new webtag soon so I can check I have calculated the same number of days as you.
Cheers,
Ray, Cheshire.

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

Re: Request for new webtag - days Cumulus has been running

Post by mcrossley »

Steve, I haven't tried it yet, but does the new tag return whole days or decimal days?
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Request for new webtag - days Cumulus has been running

Post by steve »

Whole days. And I think it truncates rather than rounding.
Steve
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Request for new webtag - days Cumulus has been running

Post by RayProudfoot »

A strange problem with my Javascript for counting the days Cumulus has been recording. It's incrementing the day counter soon after 23:00hrs rather than midnight. As I have removed the decimal element of the calculation I'm perplexed why this is happening.

I haven't yet tried Steve's new webtag for comparison. Any ideas anyone?

I'm about to hit the sack and am out for much of tomorrow.
Cheers,
Ray, Cheshire.

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

Re: Request for new webtag - days Cumulus has been running

Post by mcrossley »

Its a summer time 'thing' as your start date is in summer time, and we aren't now. Also to get the code to work in any 'clients' TZ (not GMT/BST), further manipulation is required. The start date needs to take the client TZ into account, and both start and now need to take summer time into account.

Cross TZ and DST Date/Time manipulations drive me mad :bash:

It will all get pretty messy, better to use the webtag.
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Request for new webtag - days Cumulus has been running

Post by RayProudfoot »

Thanks Mark. Why is everything so complicated? :( The webtag sounds like a good alternative.
Cheers,
Ray, Cheshire.

Image
Post Reply