Week Note Calculator

This is a very simple calculator to use to work out which week your business/project/venture is currently in, so you can put the right number into your weeknote blog post.

If you aren't sure what a "weeknote" is, then see http://weeknotes.com.

Enter the date that your business started here:
(in the form YYYY-MM-DD)

This script is provided as-is, but if anyone spots any problems or wants to get in touch then feel free to drop me an email.

The code used to calculate this is as follows:


require 'date'

registration_date = Date.civil(2005,9,30)
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
  registration_date = registration_date - (registration_date.wday - 1)

if this_week.wday == 0
  this_week = this_week - 6
  this_week = this_week - (this_week.wday - 1)

puts "This is week "+(((this_week - registration_date)/7)+1).to_s