Skip to content

Instantly share code, notes, and snippets.

@andrewn
Created October 24, 2011 14:13
Show Gist options
  • Save andrewn/1309113 to your computer and use it in GitHub Desktop.
Save andrewn/1309113 to your computer and use it in GitHub Desktop.
# From: http://www.mcqn.com/cgi-bin/weeknotecalc
def weeknote_week(this_week)
registration_date = Date.civil(2010,3,29)
# Get the start of the week for each of those dates
if registration_date.wday == 0
# wday of 0 is Sunday, and we want our weeks to start on Monday
registration_date = registration_date - 6
else
registration_date = registration_date - (registration_date.wday - 1)
end
if this_week.wday == 0
this_week = this_week - 6
else
this_week = this_week - (this_week.wday - 1)
end
week_number = (((this_week - registration_date)/7)+1).to_s
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment