Created
August 30, 2011 07:29
-
-
Save basti/1180385 to your computer and use it in GitHub Desktop.
Calculate start/end dates and next week number for given week number
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
def week_dates( year, week_no ) | |
week_start = Date.commercial( year, week_no, 1 ) | |
week_end = Date.commercial( year, week_no, 7 ) | |
week_start.strftime( "%d/%m/%y" ) + ' - ' + week_end.strftime( "%d/%m/%y" ) | |
end | |
def next_week_no(year, week_no) | |
week_start = Date.commercial( year, week_no, 1 ) | |
week_start.advance(:weeks => 1).cweek | |
end | |
# example | |
next_week_no(2008, 52) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment