开发者

in Xcode using apple script, check for system date at launch of application to validate

开发者 https://www.devze.com 2023-02-19 06:05 出处:网络
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 specif

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
0

精彩评论

暂无评论...
验证码 换一张
取 消