From: "Mark J. Reed" Date: 2003-12-05T08:27:05+09:00 Subject: Re: Swatch's internet time in Ruby [Code Inside] Pablo Lorenzzoni wrote: > : def bmt_hour > : h = self.gmtime.hour + 1 > : return 0 if h == 24 > : return h > : end The usual way of doing that is with modular arithmetic; in fact, "clock math" is the usual example of modular arithmetic given in school. In Ruby it looks like this: def bmt_hour (self.gmtime.hour + 1) % 24 end > : def beats > ((self.bmt_hour * 60 * 60) + (self.min * 60) + self.sec) / 86.4 > : end Can't really improve upon that, although I like the appearance of this formula a little better for some reason: def beats (self.bmt_hour + (self.min + self.sec / 60) / 60) / 2.4 end -Mark