Sandaysoft

Support forum for Cumulus weather station software
It is currently Thu May 23, 2013 12:16 pm
Please click here before posting. Help me to help you!
Useful Links: Cumulus FAQ • Enhancement requests • Wiki (documentation)
Please put your approximate location into your profile
Add your web site to the Cumulus user map
Vantage Pro2 users with firmware 3.00 should upgrade to fw 3.12 and Cumulus 1.9.4

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Help with Javascript
PostPosted: Sat Dec 24, 2011 5:11 am 
Offline
User avatar

Joined: Mon Dec 20, 2010 12:12 pm
Posts: 446
Location: Palmerston, NT, Australia
Weather Station: WS-1081 with rain gauge mod
Operating System: Windows 7 & 1.9.3 b1059
Can anyone see anything wrong with this?
Code:
<script type="text/javascript">

             var date = new Date();
   var y=date.getFullYear();
   var m=date.getMonth();
   var d=date.getDay();
   var h=date.getHours();
   var min=date.getMinutes();
   if (h<9)
   {var d=d-1;
   var rollover= new Date(y, m, d, 9,0,0,0);
   }else (rollover= new Date(y, m, d, 9,0,0,0));
   var now=new Date();
   var timeelapsed=now-rollover;
             
....more code follows.

Just finding the time difference (in milliseconds) between actual time and the rollover time (for me is 0900hrs).
If nothing is wrong here, then I'll have to check the rest of the code.

_________________
Michael, Palmerston, NT Australia www.Palmerston-WeatherImageNo image? I'm offline!
ImageImageImage


Top
 Profile  
 
 Post subject: Re: Help with Javascript
PostPosted: Sat Dec 24, 2011 9:20 am 
Offline
User avatar

Joined: Mon Dec 20, 2010 12:12 pm
Posts: 446
Location: Palmerston, NT, Australia
Weather Station: WS-1081 with rain gauge mod
Operating System: Windows 7 & 1.9.3 b1059
It's all done and fixed.

_________________
Michael, Palmerston, NT Australia www.Palmerston-WeatherImageNo image? I'm offline!
ImageImageImage


Top
 Profile  
 
 Post subject: Re: Help with Javascript
PostPosted: Sat Dec 24, 2011 10:25 am 
Online
User avatar

Joined: Thu Jan 07, 2010 9:44 pm
Posts: 2518
Location: Wilmslow, Cheshire, UK
Weather Station: Davis VP2
Operating System: XP SP3, Win 7
No curly brackets around your else is bad practice, you don't need 'now' as you already have now in 'date', and have you tested when d=1-1? It should work with the Date() object rolling back the month/year automatically, but worth a test of 8am on the first of January.

But don't keep us in suspense, what was the problem?

_________________
Mark
Wilmslow Astro Weather


Top
 Profile  
 
 Post subject: Re: Help with Javascript
PostPosted: Sat Dec 24, 2011 10:46 am 
Offline
User avatar

Joined: Mon Dec 20, 2010 12:12 pm
Posts: 446
Location: Palmerston, NT, Australia
Weather Station: WS-1081 with rain gauge mod
Operating System: Windows 7 & 1.9.3 b1059
MickinMoulden wrote:
Can anyone see anything wrong with this?
Code:
<script type="text/javascript">

             var date = new Date();
   var y=date.getFullYear();
   var m=date.getMonth();
   var d=date.getDay();    **getDate**is what was needed, it gives 0-31, **detDay** is 0-6!
   var h=date.getHours();
   var min=date.getMinutes();
   if (h<9)
   {var d=d-1;
   var rollover= new Date(y, m, d, 9,0,0,0);
   }else (rollover= new Date(y, m, d, 9,0,0,0));
   var now=new Date();
   var timeelapsed=now-rollover;
             
....more code follows.

Just finding the time difference (in milliseconds) between actual time and the rollover time (for me is 0900hrs).
If nothing is wrong here, then I'll have to check the rest of the code.

_________________
Michael, Palmerston, NT Australia www.Palmerston-WeatherImageNo image? I'm offline!
ImageImageImage


Top
 Profile  
 
 Post subject: Re: Help with Javascript
PostPosted: Sat Dec 24, 2011 11:36 am 
Online
User avatar

Joined: Thu Jan 07, 2010 9:44 pm
Posts: 2518
Location: Wilmslow, Cheshire, UK
Weather Station: Davis VP2
Operating System: XP SP3, Win 7
Doh! Didn't spot that one!

_________________
Mark
Wilmslow Astro Weather


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group