A
aartist
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.
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.