#!/usr/local/bin/perl # Name: mybin/days-till Author: Joe Smith 9-Apr-97 # Purpose: Displays a running countdown until a particular date # Usage: # The files [0-9].gif need to reside in same directory as html document and # should be transparent GIFs, all the same height. # One way to get the time_in_seconds for 8-Jul-95 at 2:00pm is: # /usr/5bin/touch 0708140095 /tmp/foo || touch 0708140095 /tmp/foo # perl -e 'print +(stat "/tmp/foo")[9]' # The first command line argument is the date, the remaining arguments # are a description of the event, such as "the wedding". $time = shift(@ARGV); # 805237200 = 8-Jul-95 14:00 PST # 894142800 = 2-May-98 $days = int((time - $time) / (24 * 60 * 60)); if ($days > 0) { $beforeafter = "since"; } else { $beforeafter = "until"; $days = -$days; } $_ = sprintf("%d",$days); # Convert float to int, then to string of digits print "\n

"; while (/(.)(.*)/) { # Convert string of digits to multiple GIFs print qq'$1'; $_ = $2; } print " ",($days == 1 ? "day" : "days"); printf " (%3.1f years)",$days/365.24 if $days > 365.24; print " $beforeafter @ARGV

\n\n"; exit;