Mercurial > hg > nodescore
annotate chronometer.js @ 53:a0ae699ac444
chronometer no long increments but now compares start time with current
time
author | root <root@beaglebone.(none)> |
---|---|
date | Sun, 14 Oct 2012 00:26:42 +0000 |
parents | ddb09f0a67fd |
children | 66bf613fb818 |
rev | line source |
---|---|
rc-web@49 | 1 //////////////////////////////////////////// |
rc-web@49 | 2 // Chronometer |
rc-web@49 | 3 //////////////////////////////////////////// |
rc-web@49 | 4 |
rc-web@49 | 5 // number padding: 0 to 00 |
rc-web@49 | 6 function pad(number) { return (number < 10 ? '0' : '') + number } |
rc-web@49 | 7 |
rc-web@49 | 8 function xdateTime() { |
rc-web@49 | 9 var xdatetime= new Date(); |
rc-web@49 | 10 var now=xdatetime.toString() |
rc-web@49 | 11 return now |
rc-web@49 | 12 } |
rc-web@49 | 13 |
rc-web@49 | 14 |
rc-web@49 | 15 // the chronometer initial states |
rc-web@49 | 16 function zeroChron(){ |
rc-web@49 | 17 zecsec = 0; seconds = 0; |
rc-web@49 | 18 mins = 0; hours = 0; |
rc-web@49 | 19 zero = pad(hours) +":"+pad(mins)+ ':'+ pad(seconds) |
rc-web@49 | 20 chron = zero |
rc-web@49 | 21 return zero |
rc-web@49 | 22 } |
rc-web@49 | 23 |
rc-web@49 | 24 zeroChron() |
rc-web@49 | 25 |
rc-web@49 | 26 function chronometer(divisor) { |
rc-web@49 | 27 zecsec += divisor; // set tenths of a second |
rc-web@49 | 28 if(zecsec > 9) { zecsec = 0; seconds += 1;} |
rc-web@49 | 29 if(seconds > 59) { seconds = 0;mins += 1;} |
rc-web@49 | 30 if(mins > 59) { mins = 0; hours += 1; } |
rc-web@49 | 31 chron = pad(hours) +":"+pad(mins)+ ':'+ pad(seconds)+ ":"+ zecsec |
rc-web@49 | 32 chronsec = pad(hours) +":"+pad(mins)+ ':'+ pad(seconds) |
rc-web@49 | 33 if ( divisor !== 1000 ){ |
root@53 | 34 return chron |
rc-web@49 | 35 } |
root@53 | 36 else { return chronsec } |
rc-web@49 | 37 }; |
rc-web@49 | 38 |
rc-web@49 | 39 exports.chronometer =chronometer; |
rc-web@49 | 40 exports.xdateTime = xdateTime; |
root@53 | 41 exports.zeroChron = zeroChron; |