View unanswered posts | View active topics It is currently Sat May 18, 2013 1:40 pm



Reply to topic  [ 5 posts ] 
 How do I readout the current time and display it? 
Author Message

Joined: Feb 13, 2006
Posts: 217
Location: Michigan
Post 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


Sun Apr 24, 2011 4:25 pm
Profile

Joined: Nov 26, 2009
Posts: 923
Location: Kalispell, MT
Post 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


Sun Apr 24, 2011 8:54 pm
Profile

Joined: Feb 13, 2006
Posts: 217
Location: Michigan
Post Re: How do I readout the current time and display it?
Thanks a lot. I'll try it.


Mon Apr 25, 2011 3:49 pm
Profile

Joined: Jul 20, 2011
Posts: 1
Post 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)


Thu Nov 10, 2011 2:02 pm
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6642
Location: Austin, Texas
Post 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)
Image


Thu Nov 10, 2011 2:33 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.