
Re: How do I readout the current time and display it?
As always, there's probably a better way to do this but I run this script by a Time/Date Action once every minute:
- Code: Select all
set theDate to (current date) as string
set hourWord to word 5 of theDate as integer --hour
set minWord to word 6 of theDate as integer --minute
set apWord to word 8 of theDate --AM or PM
set theHour to hourWord * 100 + minWord
if (apWord = "PM" and hourWord ≠ 12) then set theHour to theHour + 1200
if (apWord = "AM" and hourWord = 12) then set theHour to theHour - 2400
-- add leading zero if necessary
set minWordString to minWord as string
set theLength to the length of minWordString
if theLength = 1 then
set minWord to "0" & minWord as string
end if
set theClock to (hourWord as string) & ":" & minWord as string
set theDay to text 1 thru 3 of theDate
tell application "IndigoServer"
set value of variable "TimeNow" to (current date) as string
set value of variable "TimeNow2400" to theHour
set value of variable "ClockTime" to theClock
set value of variable "DayShort" to theDay
end tell
Just create the variables such as "ClockTime" and display them on a Control Page.
Carl