From: "W. Kent Starr" Date: 2001-02-22T22:59:14+09:00 Subject: [ruby-talk:11313] Re: Time without seconds... On Thursday 22 February 2001 08:44, David Alan Black wrote: > On Thu, 22 Feb 2001, DaVinci wrote: > > Hi. > > > > I want to get a Time instance without seconds (round minutes). I have > > probed next class: > > > > class MyTime < Time > > def initialize > > super > > self -= sec > > end > > end > > > > but it doesn't work. I get error: > > > > Can't change the value of self > > > > Is any form of doing this?. > > You could add a method to class Time: > > class Time > def round_to_m > self - sec > end > end > > t = Time.new > p t > p t.round_to_m > > Except that you might want to name the method 'floor' in that, by always _subtracting_ sec, you are always rounding down to the minute. Regards, Kent Starr elderburn@mindspring.com