File tree 2 files changed +16
-5
lines changed
2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -380,13 +380,13 @@ var osc = osc || {};
380
380
381
381
// TODO: Unit tests.
382
382
osc . jsTimeToNTP = function ( jsTime ) {
383
- var ms = jsTime | 0 ,
384
- secs = ( ms / 1000 ) | 0 ,
383
+ var ms = Math . floor ( jsTime ) ,
384
+ secs = ms / 1000 ,
385
+ fracSec = secs - Math . floor ( secs ) ,
385
386
secs1900 = secs + osc . SEVENTY_YEARS_SECS ,
386
- fracMs = jsTime - ms ,
387
- fracSec = ( ( fracMs / 1000 ) * 4294967296 ) | 0 ;
387
+ ntpFracs = 4294967296 * fracSec ;
388
388
389
- return [ secs1900 , fracSec ] ;
389
+ return [ secs1900 , ntpFracs ] ;
390
390
} ;
391
391
392
392
/**
Original file line number Diff line number Diff line change 434
434
435
435
timeTagTests ( timeTagTestSpecs ) ;
436
436
437
+ test ( "Write native-only time tag." , function ( ) {
438
+ var testSpec = timeTagTestSpecs [ 1 ] ,
439
+ expected = testSpec . timeTagBytes ,
440
+ timeTag = {
441
+ native : testSpec . timeTag . native
442
+ } ;
443
+
444
+ var actual = osc . writeTimeTag ( timeTag ) ;
445
+ arrayEqual ( actual , expected ,
446
+ "A time tag with no raw value (only a native value) should be written correctly." ) ;
447
+ } ) ;
437
448
438
449
/**********************************************
439
450
* Read Type-Only Arguments (e.g. T, F, N, I) *
You can’t perform that action at this time.
0 commit comments