HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: mvdarend on May 04, 2014, 08:50:07 PM

Title: Gettintg the current time
Post by: mvdarend on May 04, 2014, 08:50:07 PM
Is there a way to get the current 'HomeGenie' time?

With JavaScript I can only get UTC time and the offset. I suppose I could calculate the time from that, but as HomeGenie already uses it for scheduling I assumed it would be available for scripting.

I found a block of deprecate code in ProgramEngine.cs which had a Programs.Time value, but I can't find anything else.
Title: Re: Gettintg the current time
Post by: dutchie on May 09, 2014, 12:35:58 AM
Please notice I don't have any programming experience and maybe I didn't get your question right.

As a non programmer I don't know all the capabilities of the CronJob (I added 4 blocks of 6 hours myself with Morning, Afternoon, Evening and Night) but now I'm looking for a variable like Time is between x and y hours.

I'm trying to figure out myself, first thing what came to my mind was: OS.Time

Other things that crossed my mind are DateTime, toGMTString() and toLocaleString()

I think I'll start with experimenting with:

currentTime.getHours()
currentTime.getMinutes()

currentDate.getDate()
currentDate.getMonth()
currentDate.getFullYear()
Title: Re: Gettintg the current time
Post by: mvdarend on May 09, 2014, 09:15:33 AM
Thanks for your help dutchie, your post led me to do a more thorough Google search, I didn't realize that there were more javascript date/time functions available. I found what I needed, new Date().getHours()) (I only need the hour part.)

Basically I wanted to check the time when switch on a light with the wall switch. If before 18:00 then set the Hue lights to the 'Reading' theme, if later use the 'Relax' theme.

Thanks again