Stamp is Awesome, Don't Use Stamp
I don't think I'm alone in having a hard time remembering strftime directives or being a frequent flyer at strftime.net. So I was excited when a couple weeks ago I was introduced to a really neat gem called stamp. It's pretty simple and has one goal:
Format dates and times based on human-friendly examples, not arcane strftime directives.
Stamp is a great tool on its own but it seems to encourage bad behavior, especially when working within frameworks (like Rails) that provide better alternatives. The codebase where I was introduced to stamp was littered with stuff like:
user.signed_up_at.stamp("January 20, 2012")
… but what should have been done there was:
l user.signed_up_at, format: :short
If you're looking to display dates in a way not included in the defaults just go ahead and add something like the following to your translation file (
en: time: formats: classy: "It's %B %d, %Y... stay classy"
Stamp just makes it too easy to stop using the date/time format helpers Rails supplies, leaving you with hardcoded date formats everywhere and no way to tell which one is right. It's like giving a high interest rate credit card to a college student, (technical) debt will follow.
As much as I like the idea of stamp it just won't ever have a place in my Rails project Gemfiles. It's really not that hard to look up strftime formats and after you've built out your list of date formats a little you won't even have to do it anymore.