Last active
December 10, 2015 22:18
-
-
Save romulostorel/4501708 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
require 'active_support/all' | |
from = "01/01/2012".to_date | |
to = "31/12/2012".to_date | |
tmp = from | |
count = 0 | |
begin | |
tmp += 1.day | |
count += 1 unless tmp.saturday? || tmp.sunday? | |
end while tmp <= to | |
puts count |
fellix
commented
Jan 10, 2013
from = "01/01/2012".to_date
to = "31/12/2012".to_date
days = (from..to).reject(&:sunday?).reject(&:saturday?).size
from = "01/01/2012".to_date
to = "31/12/2012".to_date
days = (from..to).reject(&:sunday?).reject(&:saturday?).size
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment