Skip to content

Instantly share code, notes, and snippets.

@btoone
Last active December 11, 2015 07:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save btoone/4569096 to your computer and use it in GitHub Desktop.
Save btoone/4569096 to your computer and use it in GitHub Desktop.
# Inspired by https://github.com/7hunderbird
# Execute via `curl -fs https://gist.github.com/raw/4569096/373e78aa18b438e74f04a782dd5ca7416b2cb50a/countdown.rb | ruby`
# in the terminal
require 'Date'
today = Date.today
deadline = Date.new(2013, 03, 04)
num_of_days = (deadline - today).to_i
msg = "[#{num_of_days}] days left"
puts num_of_days <= 5 ? "Oh '$#!@', only " + msg : msg
@btoone
Copy link
Author

btoone commented Jan 18, 2013

Gave credit where credit was due.

@7hunderbird
Copy link

Here's my blunt original that you turned into an elegant solution. I like yours, Brandon.

# in irb
require 'activesupport'
x = Time.now.to_date
y = 'Mon, 04 Mar 2013'.to_date
(y - x).to_i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment