Created
January 18, 2011 17:04
-
-
Save razielgn/784754 to your computer and use it in GitHub Desktop.
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
require 'date' | |
require 'progressbar' | |
curr = Date.parse("01/01/0001") | |
totals = (Date.today - curr).to_i | |
pbar = ProgressBar.new "Counting", totals | |
Months = [] | |
currMonth = curr.mon | |
contSun = 0 | |
contMon = 0 | |
contSat = 0 | |
while (curr != Date.today.next_month) | |
if curr.mon != currMonth | |
currMonth = curr.mon | |
contSun = 0 | |
contMon = 0 | |
contSat = 0 | |
end | |
case curr.wday | |
when 1 then contMon += 1 | |
when 6 then contSat += 1 | |
when 0 then contSun += 1 | |
else | |
end | |
Months << "#{Date::MONTHNAMES[currMonth]} - #{curr.year}" if contMon == 5 and contSat == 5 and contSun == 5 | |
curr = curr.succ | |
pbar.inc | |
end | |
pbar.finish | |
Months.each {|mon| puts mon} | |
puts Months.size |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment