Monday_of_this_week2.rb

This content was produced by an LLM and could include errors.

This script captures the current time and calculates the exact timestamp for the previous Monday. It uses Ruby’s Time methods and day-of-week arithmetic for precise date determination.

today = Time.now
#=> 2026-05-07 12:49:20.210804334 +0000
this_monday = today - (today.wday - 1) * 24 * 60 * 60
#=> 2026-05-04 12:49:20.210804334 +0000

Ruby 4.0.3