From: Vance Heron Date: 2005-05-26T07:16:55+09:00 Subject: Re: Zerofy Try something like def zerofy! sprintf("%02d", self) end V aartist wrote: >How I can zerofy the day and month. I like to add 0 in the beginning. >Now an object cannot have 0 at the beginning unless it is a string >object in this context. > > >My code: >class Fixnum > def zerofy! > self < 10 ? '0' + self.to_s : self.to_s > end >end > > > t = Time.at(time.to_i) > day,month,year = t.to_a[3..5] > month.zerofy! > >doesn't work. > > > >