diff m-toolbox/m/gui/ltpdv/callbacks/ltpdv_server_set_duration.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/m/gui/ltpdv/callbacks/ltpdv_server_set_duration.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,33 @@
+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));
+
+