« The PSP Countdown's Source | Main | EverythingDigital Podcast 2005-03-12 »
March 12, 2005
The AppleScript Countdown
I have created a generic countdown app that can be easily modified to count down to any date (although the default is the PSP's North American arrival day). I have made this app available both as an application file (.app) and an AppleScript script file (.scpt) for editing and open-source development. Mac OS X is required and 10.3 or later is recommended.
Download AppleScript Countdown
Download AppleScript Countdown Source
Here is the source code for the AppleScript. You can copy and paste this into an editor program, or download the source .scpt file above.
repeat
set todaydate to current date
set todayday to day of todaydate
set todaytime to time of todaydate
set todayyear to year of todaydate
set launchdate to date "Thursday, March 24, 2005 12:00:00 AM"
set launchday to day of launchdate
set launchtime to time of launchdate
set launchyear to year of launchdate
set yearsleft to launchyear - todayyear
set daysleft to launchday - todayday
set timeleft to 86400 - todaytime
set totaltimeleft to timeleft + {86400 * daysleft}
set totaltotaltimeleft to totaltimeleft + {yearsleft * 31536000}
set unroundedminutesleft to totaltotaltimeleft / 60
set totalminutesleft to {round unroundedminutesleft}
set unroundedhoursleft to totalminutesleft / 60
set totalhoursleft to {round unroundedhoursleft}
set unroundeddaysleft to totalhoursleft / 24
set totaldaysleft to {round unroundeddaysleft}
set unroundedyearsleft to totaldaysleft / 365
set totalyearsleft to {round unroundedyearsleft}
if totaltotaltimeleft is less than or equal to 0 then
display dialog "The wait is finally over!"
exit repeat
else
display dialog "There are...
" & totalyearsleft & " years,
" & totaldaysleft & " days,
" & totalhoursleft & " hours,
" & totalminutesleft & " minutes, or
" & totaltotaltimeleft & " seconds left until the countdown is over.
This dialog will auto-refresh every 10 seconds, or you can manually refresh it by clicking OK." giving up after 10
end if
end repeat
Posted by Alan Joyce at March 12, 2005 08:14 PM
Trackback Pings
TrackBack URL for this entry:
http://www.everythingdigital.org/cgi-bin/mt-tb.cgi/139
Listed below are links to weblogs that reference The AppleScript Countdown:
» Do it yourself "Death Clock" from MAKE: Blog
I don't mean to be morbid, but I thought this was a fun clock to make to remin... [Read More]
Tracked on March 14, 2005 12:04 AM
Comments
do you make a countdown timer to be used on/for windows xp
Posted by: mike at March 27, 2006 08:29 AM
Unfortunately, no. This timer is written in applescript, and therefore supports only the Mac platform.
Posted by: Alan Joyce at March 28, 2006 03:07 PM