Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Struggling with date and time types Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
dhewison
Newbie
Newbie


Joined: February 28 2008
Location: United Kingdom
Online Status: Offline
Posts: 25
Posted: March 30 2008 at 05:08 | IP Logged Quote dhewison

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 View dhewison's Profile Search for other posts by dhewison
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: March 30 2008 at 09:13 | IP Logged Quote TonyNo

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 View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhewison
Newbie
Newbie


Joined: February 28 2008
Location: United Kingdom
Online Status: Offline
Posts: 25
Posted: April 02 2008 at 10:57 | IP Logged Quote dhewison

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 View dhewison's Profile Search for other posts by dhewison
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 02 2008 at 13:21 | IP Logged Quote TonyNo

I believe that the US changes at 02:00.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: April 02 2008 at 13:55 | IP Logged Quote dhoward

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 View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
dhewison
Newbie
Newbie


Joined: February 28 2008
Location: United Kingdom
Online Status: Offline
Posts: 25
Posted: April 03 2008 at 07:51 | IP Logged Quote dhewison

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 View dhewison's Profile Search for other posts by dhewison
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: April 03 2008 at 11:02 | IP Logged Quote BeachBum

Checkout Tony's GETWEATHER. I think that would be close to what you want.

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
dhewison
Newbie
Newbie


Joined: February 28 2008
Location: United Kingdom
Online Status: Offline
Posts: 25
Posted: April 03 2008 at 12:25 | IP Logged Quote dhewison

Excellent, thanks for that

- David
Back to Top View dhewison's Profile Search for other posts by dhewison
 
dhewison
Newbie
Newbie


Joined: February 28 2008
Location: United Kingdom
Online Status: Offline
Posts: 25
Posted: April 07 2008 at 12:51 | IP Logged Quote dhewison

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 View dhewison's Profile Search for other posts by dhewison
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum