Ron Lusk on 17 Dec 2005 15:03:20 -0000 |
Oh for goodness' sake, it's not like you're locked into the C Standard Library! :-) class Time alias_method :orig_strftime,:strftime # Ditz with strftime to accept '&m' and '&d' as format codes for # month and day without padding out to two characters. (Does not # at the moment handle embedded '&m' that should be there.) def strftime(x) result = orig_strftime(x) result.gsub!(/&m/) {"%d" % self.month} result.gsub!(/&d/) {"%d" % self.day} result end end t = Time.local(2005,3,4,18,2,17) t.strftime('&m/&d/%Y') => "3/4/2005" -- Ron Lusk ronlusk@alum.mit.edu _______________________________________________ talk mailing list talk@phillyonrails.org http://lists.phillyonrails.org/mailman/listinfo/talk
|
|