Powered byAppUnite LogoBlog
new-year-6570372.png

TIL: Welcome 2022 - :invalid_date

| 1 min read

new-year-6570372.png

Monday, 03.01.2022. I'm starting to develop a new feature and instantly see interesting test errors.

Untitled.png

What is the reason of such an issue?

deleted_at =
    DateTime.new!(
        Date.new!(today.year - 5, today.month - 1, today.day),
        ~T[12:00:00]
    )

The answer is as easy as ABC. We subtract 1 from 1 (January) and get month 0.

Conclusion:

Be careful while manipulating on dates.