Thanks for replying so quickly!
I eventually found a script that works, but I find it hard to believe that it needs to be this long. Any suggestions for something more efficient would be great.
- Code: Select all
set alarm to value of variable "Alarm"
set alarmoff to value of variable "ALARM_OFF"
set myDate to current date
set now to current date
dateObject from value of variable "TS_LAST_DETECTION" into myDate
if myDate < (now - 2 * hours) then
set value of variable "log" to "true"
return true
else
set value of variable "log" to "false"
return false
end if
to dateObject from theDateString into myDate
set {oti, text item delimiters} to {text item delimiters, " "}
set {dateString, timeString} to text items of theDateString
set text item delimiters to ":"
set {hrs, mins} to text items of timeString
set hrsMins to hrs * hours + mins * minutes
set {yr, Mnth, dy} to words of dateString
set the time of myDate to hrsMins
set the year of myDate to yr
set the month of myDate to Mnth
set the day of myDate to dy
set text item delimiters to oti
end dateObject