From: Alex Gutteridge Date: 2007-08-16T14:06:16+09:00 Subject: Re: excessively verbose request for help with regex and arrays On 16 Aug 2007, at 13:46, Simon Schuster wrote: > thanks, but since the time is only going to be used for arithmetic > parsing it for additional information isn't helpful, and the roll-over > will be problematic. > > (23:54:45) - (00:03:45) != 00:09:00 Does this help? Parse the two dates like Eric suggested. If the second (later) time is less than the first then add a day to it (60*60*24 seconds). Then subtract one from the other to get the difference in seconds. irb(main):023:0> t1 = Time.parse('23:54:45') => Thu Aug 16 23:54:45 +0900 2007 irb(main):024:0> t2 = Time.parse('00:03:45') => Thu Aug 16 00:03:45 +0900 2007 irb(main):025:0> t2 += (60 * 60 * 24) if t2 < t1 => Fri Aug 17 00:03:45 +0900 2007 irb(main):026:0> diff = t2 - t1 => 540.0 Alex Gutteridge Bioinformatics Center Kyoto University