function ltpdv_server_set_duration(mainfig, start, stop)

% Get handle
dh = findobj(mainfig, 'Tag', 'LTPDVserverDurationDisplay');

% Get duration
dur = stop - start + 1;

if dur < 0
  error('### The duration is negative. Change the start or stop time.');
end

hours = fix(dur/3600);
mins  = fix((dur-hours*3600)/60);
secs  = dur-hours*3600-mins*60;

sign = '';
if hours < 0
   sign = '-';
   hours = abs(hours);
end
if mins < 0
   sign = '-';
   mins = abs(mins);
end
if secs < 0
   sign = '-';
   secs = abs(secs);
end

set(dh, 'String', sprintf('%s%02d:%02d:%02d', sign, hours, mins, secs));


