From: Simon Schuster Date: 2007-08-16T14:21:22+09:00 Subject: Re: excessively verbose request for help with regex and arrays yes, this helps a lot! I should have assumed that parsing the time would enable arithmetic like Fri - Thurs, instead I assumed I'd have to put it all to integers. I will have to think over more of exactly what I'm trying to do with the arrays/hashes, after I read more about hashes, I think. thanks! On 8/15/07, Alex Gutteridge wrote: > 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 > > > >