#more_than? and #less_than? for date-like object monkey patching in activesupport

Hey all :wave:t2:

I often find myself comparing date-like objects with < and >, and often get the ordering wrong because (imo) it is not an intuitive way to think about dates. For example, I want to know if an object is more than a month old:

some_object.created_at < 1.month.ago

Would there be appetite for something more ergonomic like:

some_object.created_at.more_than?(1.month.ago)

This feels rails-y, and given the extensions on date-like objects which currently exist, the implementation would be straightforward.

Thanks!

Maybe before? and after? is what you want:

2 Likes

Thank you! Feel very silly for not knowing these exist :smile: