From: Paul Lutus Date: 2006-11-27T03:25:14+09:00 Subject: Re: Timestamp Srinivas Sa wrote: > Sorry for not being clear; I am trying to work on merging subtitle files > which holds the subtitles of a movie. They have the HH:MM:SS,nnn and > sentence that need to be flashed at that moment on the screen. Break it down for us. What does ",nnn" signify? Here is how to get the components: a = "23:56:33,9876" h,m,s,n = a.scan(%r{(\d{2}):(\d{2}):(\d{2}),(\d+)}).flatten Each of the results is a string, chances are you want to convert them into integers and then add them up to get a result expressed in seconds: elapsed = h.to_i * 3600 + m.to_i * 60 + s.to_i Now you can add or subtract elapsed times using the "elapsed" results. Then reconvert the elapsed time expressed as an integer into hours, minutes, and seconds: s = elapsed % 60 elapsed /= 60 m = elapsed % 60 elapsed /= 60 h = elapsed > > I just need to know how to add up two time stamps so that i can merge > the two files and make it one continuous sequence of subtitles. E.g. > > 00:24:25,700 + 00:00:03,800 should yield 00:24:29,500 > > I don't bother what date (YY/MM/DD part) it is gonna be when I add up, > it can be anything. You simply must put up enough code so we can discover your error. You have posted the line where the error occurs, but not the code that produces the error and delivered it to that line. Since you don't seem inclined to post your code, my advice is to start over and use methods like those shown above. -- Paul Lutus http://www.arachnoid.com