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:


#!/usr/bin/ruby

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
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