I’m learning how to build an interactive calendar UI with Rails and Hotwire. Take a look at this nicely designed calendar from Tailwind UI.
I wondered how I would generate a full month’s dates but also include the last week of the previous month and the first week of the following month enough to fill in a 7x5 or 7x6 grid. Luckily, Rails has some handy date helpers that make this easy, and they read like I’m writing a sentence.
I love how that one line will generate the exact date range I need. Take a look at the docs for
DateAndTime::Calculations to learn more about the