Heads up: This description was created by AI and might not be 100% accurate.

monday_of_this_week1.rb

This Ruby code snippet demonstrates date manipulation. It first requires the date library. Then, it gets the current date and calculates the date of this Monday by subtracting the day of the week from the current date and adding 1. The result is the Date object representing this Monday.

Ruby code snippet

require 'date'
#=> true

today = Date.today
#=> #<Date: 2025-07-27 ((2460884j,0s,0n),+0s,2299161j)>
this_monday = today - today.wday + 1
#=> #<Date: 2025-07-28 ((2460885j,0s,0n),+0s,2299161j)>

Executed with Ruby 3.4.5.