Created
December 18, 2011 16:03
-
-
Save fredoliveira/1493778 to your computer and use it in GitHub Desktop.
Script to calculate the current week for weekly notes
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
#!/usr/bin/ruby | |
require 'date' | |
registration_date = Date.civil(2006,1,13) | |
this_week = Date.today | |
# 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 | |
puts "This is week "+(((this_week - registration_date)/7)+1).to_s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment