Date Ruby

require 'date'
module Week
  def week
    (yday + 7 - wday) / 7
  end
end
class Date
  include Week
end
class Time
  include Week
end
saturday = DateTime.new(2005, 1, 1)
saturday.week                                    # => 0
(saturday+1).week                                # => 1   #Sunday, January 2
(saturday-1).week                                # => 52  #Friday, December 31