Calculate Time Issue

Posted on
Wed Jul 24, 2013 10:18 am
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Calculate Time Issue

This script is working fine to calculate my hot tub ready time based on it's current temp, but I'm hoping it can be modified to not include the seconds. Need to have 12:00 AM, instead of 12:00:00 AM

Appreciate any help!

Thanks,

Carl

Code: Select all
tell application "IndigoServer"
   set theTemp to (value of variable "wsTemp_HotTub" as integer)
   set timeNow to (value of variable "ClockTimeAmPm")
end tell

set theTime to ((95 - theTemp) / 10) * hours
set readyTime to time string of ((date timeNow) + theTime)

tell application "IndigoServer" to set the value of variable "HotTubReadyTime" to readyTime

Posted on
Wed Jul 24, 2013 2:53 pm
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Calculate Time Issue

Try...

Code: Select all
tell application "IndigoServer"
   set theTemp to (value of variable "wsTemp_HotTub" as integer)
   set timeNow to (value of variable "ClockTimeAmPm")
end tell

set theTime to ((95 - theTemp) / 10) * hours
set readyTime to time string of ((date timeNow) + theTime)
-- New code
if readyTime contains "AM" then
   set ampm to " AM"
else
   set ampm to " PM"
end if
set AppleScript's text item delimiters to ":"
set readyTime to text item 1 of readyTime & ":" & text item 2 of readyTime & ampm
set AppleScript's text item delimiters to {""}
-- End new code.
tell application "IndigoServer" to set the value of variable "HotTubReadyTime" to readyTime


AppleScript isn't real elegant when it comes to string pattern substitutions, so it's not real elegant, but it should work.

Posted on
Wed Jul 24, 2013 4:29 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Calculate Time Issue

As always, works perfect. Thanks Nathan!

Carl

Posted on
Wed Jul 24, 2013 4:35 pm
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Calculate Time Issue

:-D Great! Glad it worked.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 28 guests