more G-Labs products

Author Topic: Gettintg the current time  (Read 1344 times)

May 04, 2014, 08:50:07 PM
Read 1344 times

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
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.

May 09, 2014, 12:35:58 AM
Reply #1

dutchie

  • **
  • Information
  • Jr. Member
  • Posts: 47
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()

May 09, 2014, 09:15:33 AM
Reply #2

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
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