Skip to content

Instantly share code, notes, and snippets.

@romulostorel
Last active December 10, 2015 22:18
Show Gist options
  • Save romulostorel/4501708 to your computer and use it in GitHub Desktop.
Save romulostorel/4501708 to your computer and use it in GitHub Desktop.
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
Copy link

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

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