Skip to content

Instantly share code, notes, and snippets.

@pote
Created November 8, 2012 19:19
Show Gist options
  • Save pote/4040908 to your computer and use it in GitHub Desktop.
Save pote/4040908 to your computer and use it in GitHub Desktop.
Simple script to calculate how far from my target hours whenever I want to.
require 'date'
today = Date.today
beginning_of_month = Date.parse("#{today.year}-#{today.month}-1")
workable_days_until_now = (beginning_of_month..today).reject { |d| d.saturday? || d.sunday? }.count
optimum_hours_until_now = workable_days_until_now * 6
puts "Workable days until now: #{ workable_days_until_now }"
puts "Optimum hours until now: #{ optimum_hours_until_now }"
@dcadenas
Copy link

dcadenas commented Nov 8, 2012

There's also

today = Date.today
beginning_of_month = today - today.day + 1

@alfius
Copy link

alfius commented Nov 8, 2012

mmm, interesting...

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