Author |
|
dhewison Newbie
Joined: February 28 2008 Location: United Kingdom
Online Status: Offline Posts: 25
|
Posted: March 30 2008 at 05:08 | IP Logged
|
|
|
Hi,
I am just playing with scripting in powerhome and I am struggling with passing date and time types between script and power. An example is that I am trying to determine if the current date is in daylight savings time or not. In playing around I set a powerhome global variable called "DATETIME" to the current date and time and then test for daylight savings against the content of this variable and set another variable "DAYLIGHTSAVING" with the result. I currently seem to get different results if I use scripting or a formula, as follows:
Variable "DATETIME" = 30/03/2008 09:56:11.139
Formula "ph_isdaylightsavings(ph_getglobal_dt("DATETIME"))" returns a 1.
Script line "daylightsaving = ph.isdaylightsavings(ph.getglobal_dt("DATETIME"));" returns a 0.
I can't for the life of me see what I'm doing wrong at the moment, can anyone point out my blunder ?
- David
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: March 30 2008 at 09:13 | IP Logged
|
|
|
My guess would be that the ph[_.]isdaylightsavings functions need a date variable, not a DateTime.
Try: ph.isdaylightsavings(ph.getglobal_d("DATETIME"));
|
Back to Top |
|
|
dhewison Newbie
Joined: February 28 2008 Location: United Kingdom
Online Status: Offline Posts: 25
|
Posted: April 02 2008 at 10:57 | IP Logged
|
|
|
What is the offical time of change to DST ? In the UK we change from GMT/UTC to BST/DST at 01:00 which means that the first hour of that day is still GMT.
I think I've been down the date route and found it very problematic setting powerhome date variables from jscript, I'm sure that is the root o the problem. I will have another go as soon as I've got a moment, although I decided to do most of the work in jscript instead of using powerhome functions.
- David
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 02 2008 at 13:21 | IP Logged
|
|
|
I believe that the US changes at 02:00.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: April 02 2008 at 13:55 | IP Logged
|
|
|
David,
Tony nailed it. The problem is that the ph_isdaylightsavings function wants a Date value and not a datetime value. You would want to modify your formula to be:
ph_isdaylightsavings(ph_getglobal_d("DATETIME"))
Also, when storing dates and datetime data within global or system variables (basically string data), it's best to structure them in this format:
yyyy-mm-dd hh:mm:ss.fff
Obviously, you don't have to include .fff if your time component doesnt go down to milliseconds.
If you make the changes above, then your results should be consistent across platforms.
Also, in the US, DST changes are at 0200.
Hope this helps,
Dave.
|
Back to Top |
|
|
dhewison Newbie
Joined: February 28 2008 Location: United Kingdom
Online Status: Offline Posts: 25
|
Posted: April 03 2008 at 07:51 | IP Logged
|
|
|
Many thanks to both of you, I will take this into account in the rest of my project.
By the way, I'm developing a script that downloads weather reports from a web site and uses temperature and maybe wind speed to adjust heating control within the house. Do you know if I'm just re-inventing the wheel and is there a script already available to do this ?
- David
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: April 03 2008 at 11:02 | IP Logged
|
|
|
Checkout Tony's GETWEATHER. I think that would be close to what you want.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
dhewison Newbie
Joined: February 28 2008 Location: United Kingdom
Online Status: Offline Posts: 25
|
Posted: April 03 2008 at 12:25 | IP Logged
|
|
|
Excellent, thanks for that
- David
|
Back to Top |
|
|
dhewison Newbie
Joined: February 28 2008 Location: United Kingdom
Online Status: Offline Posts: 25
|
Posted: April 07 2008 at 12:51 | IP Logged
|
|
|
How do I pass datetime types from jscript to powerhome? Although Jscript's date type includes date and time information I cannot find a way of using this in powerhome, for instance when trying to create a timed event.
- David
|
Back to Top |
|
|