-
-
Save anonymous/556d5864579da6bb60d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc(h,m,s,ms,op,t1,t2) | |
ts = t1 | |
tms = t2 | |
if op==1 | |
total_s =s+ts | |
total_m= 0 | |
total_h= 0 | |
total_ms = ms+tms | |
if total_ms > 999 | |
total_s = total_s+1 | |
total_ms = total_ms - 1000 | |
if total_s > 59 | |
total_m = total_m+1+m | |
total_s = total_s - 60 | |
if total_m > 59 | |
total_h = total_h+1+h | |
total_m = total_m - 60 | |
end | |
end | |
end | |
if total_h < 9 | |
total_h = "0"+total_h.to_s | |
else | |
total_h = total_h.to_s | |
end | |
if total_m < 9 | |
total_m = "0"+total_m.to_s | |
else | |
total_m = total_m.to_s | |
end | |
if total_s < 9 | |
total_s = "0"+total_s.to_s | |
else | |
total_s = total_s.to_s | |
end | |
if total_ms < 9 | |
total_ms = "00"+total_ms.to_s | |
elsif total_ms =tms | |
total_ms = ms-tms | |
else | |
tmp = tms-ms | |
total_ms = 1000-tmp | |
total_s = total_s-1 | |
end | |
newt = ts+total_s | |
if s>= newt | |
if newt 59 | |
total_m = total_m-1-m | |
total_s = total_s - 60 | |
if total_m > 59 | |
total_h = total_h-1-h | |
total_m = total_m - 60 | |
end | |
end | |
if total_h < 9 | |
total_h = "0"+total_h.to_s | |
else | |
total_h = total_h.to_s | |
end | |
if total_m < 9 | |
total_m = "0"+total_m.to_s | |
else | |
total_m = total_m.to_s | |
end | |
if total_s < 9 | |
total_s = "0"+total_s.to_s | |
else | |
total_s = total_s.to_s | |
end | |
if total_ms < 9 | |
total_ms = "00"+total_ms.to_s | |
elsif total_ms ') | |
st = temp[0].strip | |
et = temp[1].strip | |
temp = st.split(':') | |
hh1 = temp[0].strip | |
mm1 = temp[1].strip | |
ss1 = temp[2].strip | |
temp = ss1.split(',') | |
ss1 = temp[0].strip | |
ms1 = temp[1].strip | |
temp = et.split(':') | |
hh2 = temp[0].strip | |
mm2 = temp[1].strip | |
ss2 = temp[2].strip | |
temp = ss2.split(',') | |
ss2 = temp[0].strip | |
ms2 = temp[1].strip | |
if options.operation == :add | |
op=1 | |
else | |
op=0 | |
end | |
final1 = calc(hh1.to_i, mm1.to_i, ss1.to_i, ms1.to_i,op,ts.to_i,tms.to_i) | |
final2 = calc(hh2.to_i, mm2.to_i, ss2.to_i, ms2.to_i,op,ts.to_i,tms.to_i) | |
otext = final1+' --> '+final2 | |
end | |
end | |
File.open(output_file, 'w') do |f2| | |
f2.puts otext | |
end | |
end | |
end | |
options = ShiftSubtitle.parse(ARGV) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment