#!/usr/bin/env ruby # # Copyright 2007-2008 David Shakaryan # Distributed under the terms of the GNU General Public License v2. # Calculate seconds remaining; specify the date or time here. s = Time.local(2008,8,15,17).to_i - Time.now.to_i # Exit with an error message if the supplied time is in the past. if s < 0 puts 'You can not go back in time, idiot.' exit 1 end # Calculate days, hours and minutes remaining. d, s = s.divmod(60*60*24) h, s = s.divmod(60*60) m, s = s.divmod(60) # Output time remaining. print "#{d} days, " unless d.zero? print "#{h} hours, " unless h.zero? print "#{m} minutes, " unless m.zero? puts "#{s} seconds"