I am trying to find the seconds difference from getTime to timestr but I don’t seem to understand where I am going wrong. I think it is because I am adding one to the min and hour regardless of where it has been 60 (time units) or not.
set timestr to "11:46:23 AM"
set text item delimiters to " "
set FutureEnding to text item 2 of timestr
set text item delimiters to ":"
set FutureHour to text item 1 of timestr
set FutureMin to text item 2 of timestr
set FutureSec2 to text item 3 of timestr
set text item delimiters to " "
set FutureSec to text item 1 of FutureSec2
set getTime to "7:37:12 PM"
set text item delimiters to " "
set theEnding to text item 2 of getTime
set text item delimiters to ":"
set theHour to text item 1 of getTime
set theMin to text item 2 of getTime
set theSec1 to text item 3 of getTime
set text item delimiters to " "
set theSec to text item 1 of theSec1
if theEnding = "PM" then
set theHour to theHour + 12
end if
if FutureSec = "00" then
set FutureSec to 60
end if
set SecondsLeft to FutureSec - theSec
set theMin to theMin + 1
if FutureMin = "00" then
set FutureMin to 60
end if
set MinLeft to FutureMin - theMin
set theHour to theHour + 1
set HoursLeft to theHour - FutureHour
display dialog theHour
display dialog FutureHour
set HIHI to (24 - theHour) + FutureHour
display dialog HIHI
if HoursLeft < 0 then set HoursLeft to -HoursLeft
set SecondsToDelay to (HoursLeft * 60 * 60) + (MinLeft * 60) + (SecondsLeft)
display dialog SecondsLeft
display dialog MinLeft
display dialog HoursLeft
display dialog SecondsToDelay