Created
October 24, 2011 14:13
-
-
Save andrewn/1309113 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
# 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