Sunrise Sunset - just time without date?

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
TonyG
Member
Posts: 94
Joined: Wed Jul 22, 2009 7:35 am

Sunrise Sunset - just time without date?

Post by TonyG »

Just a quickie - I'm trying to display Sunrise and Sunset time, without dates. I've looked at program options which gives some very useful options for time & date format, but not sunrise sunset?

Detail I know, but ideally I want to use a large font and not crowd the screen.

Cheers,

Tony
ScottBot
Site Admin
Posts: 2787
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Sunrise Sunset - just time without date?

Post by ScottBot »

It would be easy to do with a script (Script Device). You would just need to setup a task that executes every time the sun/rise/set time changes to run the script. You will also need a new property value to store it. But something like this would work.

Code: Select all

' Get the formatted Property Value.  This will be formatted something like 'hh:mm' where hh is in 24 hour format.
szFormatted = GetPropertyValue("System Time.Sunrise Time")

' Let VB break out the time components into its own format
szTime = TimeValue(szFormatted)
nHour = int( datepart("h",szTime) )
nMinute = int( datepart("n",szTime) )

' Set the HouseBot normalized Property value correctly.
SetPropertyValue "Your Device.Your New Property to hold the time", "Hour=" & nHour & ",Minute=" & nMinute
Scott
TonyG
Member
Posts: 94
Joined: Wed Jul 22, 2009 7:35 am

Re: Sunrise Sunset - just time without date?

Post by TonyG »

Thanks Scott,

That should do nicely. Haven't put it into practice yet as I know it will take a little longer than it should - but should be good practice for myself.
TonyG
Member
Posts: 94
Joined: Wed Jul 22, 2009 7:35 am

Re: Sunrise Sunset - just time without date?

Post by TonyG »

Scott,

Worked a treat. This is the version that gave me the times in the format ideal for my UI:

' Get the formatted Property Value. This will be formatted something like 'hh:mm' where hh is in 24 hour format.
szFormatted = GetPropertyValue("System Time.Sunrise Time")

' Let VB break out the time components into its own format
szTime = TimeValue(szFormatted)
nHour = int( datepart("h",szTime) )
nMinute = int( datepart("n",szTime) )

' Set the HouseBot normalized Property value correctly.
SetPropertyValue "Sunrise.Simplified Sunrise Time", "0" & nHour & ":" & nMinute

' Get the formatted Property Value. This will be formatted something like 'hh:mm' where hh is in 24 hour format.
szFormatted = GetPropertyValue("System Time.Sunset Time")

' Let VB break out the time components into its own format
szTime = TimeValue(szFormatted)
nHour = int( datepart("h",szTime) )
nMinute = int( datepart("n",szTime) )

' Set the HouseBot normalized Property value correctly.
SetPropertyValue "Sunrise.Simplified Sunset Time", nHour & ":" & nMinute

Thanks again for your prompt help.

Tony
Post Reply