require 'date'
# Adds a specified number of weeks to the current system date.
#
# @param weeks [Integer] The number of weeks to add (supports negative numbers to subtract).
# @return [Date] The resulting future date as a Date object.
def add_weeks_to_current_date(weeks)
# 1. Get the current calendar date using standard Date library
current_date = Date.today
# 2. Add weeks by converting them to days (1 week = 7 days)
# Ruby's Date class automatically handles month/year boundaries and leap years.
current_date + (weeks * 7)
end
# ==========================================
# Example Usage:
# ==========================================
weeks_to_add = 4
# Calculate the future date
future_date = add_weeks_to_current_date(weeks_to_add)
# Output formatted as YYYY-MM-DD
puts "Today: #{Date.today}"
puts "After adding #{weeks_to_add} weeks: #{future_date}"
# run:
#
# Today: 2026-11-08
# After adding 4 weeks: 2026-12-06
#