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
Sunrise Sunset - just time without date?
Re: Sunrise Sunset - just time without date?
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
Re: Sunrise Sunset - just time without date?
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.
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.
Re: Sunrise Sunset - just time without date?
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
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