Skip to content

Instantly share code, notes, and snippets.

@ckgagan
Created April 3, 2012 11:27
Show Gist options
  • Save ckgagan/2291153 to your computer and use it in GitHub Desktop.
Save ckgagan/2291153 to your computer and use it in GitHub Desktop.
Get date range for given week of year
require 'date'
def week_dates( week_num )
year = Time.now.year
week_start = Date.commercial( year, week_num, 1 )
week_end = Date.commercial( year, week_num, 7 )
week_start.strftime( "%e %B" ) + ' - ' + week_end.strftime(
"%e %B" )
end
puts week_dates(22)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment