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

monday_of_this_week2.rb

This Ruby code snippet demonstrates calculating the date of this Monday. It first gets the current time using Time.now. Then, it calculates the number of seconds to subtract from the current time to reach the previous Monday, using today.wday to determine the day of the week and performing the necessary subtraction in seconds. The result, this_monday, holds the timestamp for this Monday.

Ruby code snippet

today = Time.now
#=> 2025-07-27 23:54:05.597254349 +0000
this_monday = today - (today.wday - 1) * 24 * 60 * 60
#=> 2025-07-28 23:54:05.597254349 +0000

Executed with Ruby 3.4.5.