Added to_format to Date, DateTime, and Time
Reported by Jason (crash2burn) | September 7th, 2008 @ 12:01 AM
This is a simple core extension to allow a "to_format" method be called on Date, DateTime, or Time objects. You pass in a symbol that corresponds to a key in Merb::Helpers::DateAndTime::date_formats and it will output your date in that format. I am not sure how needed this is.. but figured it might be useful. It is similar to rails' to_s(:format) extension, but much simpler and I did not want to add any execution time to .to_s, so i separated it out into its own method.
Comments and changes to this ticket
-

-
Michael Klishin (antares) September 7th, 2008 @ 01:55 AM
- → Assigned user changed from to Michael Klishin (antares)
- → State changed from new to invalid
We prefer no adding methods to core classes unless it really really simplifies things. Ruby has Time#strftime that works.
-
-

Jason (crash2burn) September 8th, 2008 @ 11:36 PM
As far as I know extlib is a dependency of merb, thus giving people no choice whether or not to have this convenience feature. This is why I originally posted it here (in the extlib section of the helpers); because if you are installing helpers, you probably don't mind some convenience features that help! Either way as I mentioned I wasn't sure if it belonged in merb and was just offering it up, yielding to the experience of you guys. Interesting thought though Bryan (as I personally like this shortcut, and it will be part of my personal lib), guess we'll see what the others think ;)
-
Matt Aimonetti (mattetti) September 23rd, 2008 @ 11:37 AM
- → Tag changed from merb-plugins patch to merb-plugins patch
@jason note that merb_plugins now has DateTime.formatted(:format) which is pretty close to what you were after.
-

Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
