How do I readout the current time and display it?

Posted on
Sun Apr 24, 2011 4:25 pm
rainman50 offline
Posts: 295
Joined: Feb 13, 2006
Location: Michigan

How do I readout the current time and display it?

I'd like to get the current time and place it into a control page .

Thanks,

Dave

Posted on
Sun Apr 24, 2011 8:54 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

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

Posted on
Mon Apr 25, 2011 3:49 pm
rainman50 offline
Posts: 295
Joined: Feb 13, 2006
Location: Michigan

Re: How do I readout the current time and display it?

Thanks a lot. I'll try it.

Posted on
Thu Nov 10, 2011 2:02 pm
texnick offline
Posts: 1
Joined: Jul 20, 2011

Re: How do I readout the current time and display it?

Thanks very much, this worked like a charm just by creating a schedule to run an embedded applescript. (no action needed separately)

Posted on
Thu Nov 10, 2011 2:33 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: How do I readout the current time and display it?

With Indigo 5 it's even easier - use the Insert Timestamp into Variable action in the Action Collection plugin. No scripting required and virtually unlimited formatting options using the Python format specifiers (if you want to override the default).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 12 guests