module CoreExtensions
  module Date
    module EpochWeek
      EPOCH_BASE = ::Date.new(1969, 12, 29) # MONDAY!!!!!
      # we're goot until 2038
      def epoch_week
        return ((self - EPOCH_BASE).to_i / 7).floor
        iso_string = iso8601
        result = 52 * cwyear + cweek
        return result if iso_string < '2021-01-04'
        result += 1
        return result if iso_string < '2027-01-04'
        result += 1
        return result if iso_string < '2031-12-29'
        result + 1
      end
    end
  end
end

Date.include CoreExtensions::Date::EpochWeek
