Created
October 2, 2012 02:12
-
-
Save softr8/3815777 to your computer and use it in GitHub Desktop.
SG 1 oct
This file contains hidden or 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
# Como usarlo: | |
# ruby sleep.rb "6:15 AM" | |
# ruby sleep.rb | |
require 'date' | |
require 'time' | |
desired_hour = ARGV.first || "7 AM" | |
wakeup_at = Time.parse("#{Date.today} #{desired_hour}") | |
SLEEP_INTERVAL = 90 * 60 # in seconds | |
MIN_SLEEP = 90 * 3 * 60 # in seconds | |
intervals = [] | |
4.times do |index| | |
intervals << (wakeup_at - MIN_SLEEP - SLEEP_INTERVAL * index).strftime("%I:%M %p") | |
end | |
last_chance = intervals.reverse!.pop | |
puts "#{intervals.join(', ')} or #{last_chance}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment