in Xcode using apple script, check for system date at launch of application to validate
I am writing a mac application using Xcode with applescript base. I want to add in a set of c开发者_Python百科ode so upon program launch, it would compare with system date. If date within range specified, proceed. If date check is out of range then terminate program immediately.
Can anyone offer any suggestions? thank you!
Xcode: 3.2.5 OSX 10.6 Snow Leopard
Do you mean something like this?
set range to 3 * days
set targetDate to (date "Saturday, March 19, 2011 12:00:00 AM")
set currDate to current date
if abs(targetDate - currDate) > range then
    display dialog "quit"
else
    display dialog "continue"
end if
on abs(n)
    if n < 0 then
        return -n
    else
        return n
    end if
end abs
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论