Last active
December 11, 2015 07:49
-
-
Save btoone/4569096 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
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
Gave credit where credit was due.