module CoreExtensions
  module Time
    module EpochWeek
      #EPOCH_BASE = -262800 # ::Time.at(0).utc.beginning_of_week # MONDAY!!!!!
      EPOCH_BASE = 259200 # -1*::Time.at(0).utc.beginning_of_week.to_i # MONDAY!!!!! '1969-12-29T00:00:00Z'.to_time.to_i + Time::EPOCH_BASE should be zero
      def epoch_week
        ((to_i + EPOCH_BASE) / 604800).floor
      end
    end
  end
end

Time.include CoreExtensions::Time::EpochWeek
