Skip to content

Commit

Permalink
fixes #38 support for higher framerates
Browse files Browse the repository at this point in the history
  • Loading branch information
m1tk4 committed Dec 13, 2023
1 parent 09812ef commit 25db286
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
14 changes: 5 additions & 9 deletions smpte-timecode.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
}
else if (typeof timeCode === 'string') {
// pick it apart
var parts = timeCode.match('^([012]\\d):(\\d\\d):(\\d\\d)(:|;|\\.)(\\d\\d)$');
var parts = timeCode.match('^([012]\\d):(\\d\\d):(\\d\\d)(:|;|\\.)(\\d+)$');
if (!parts) throw new Error("Timecode string expected as HH:MM:SS:FF or HH:MM:SS;FF");
this.hours = parseInt(parts[1]);
this.minutes = parseInt(parts[2]);
Expand Down Expand Up @@ -180,17 +180,13 @@
else throw new Error('Unsupported string format');
}
return "".concat(
this.hours<10 ? '0' : '',
this.hours.toString(),
String(this.hours).padStart(2,'0'),
':',
this.minutes<10 ? '0' : '',
this.minutes.toString(),
String(this.minutes).padStart(2,'0'),
':',
this.seconds<10 ? '0' : '',
this.seconds.toString(),
String(this.seconds).padStart(2,'0'),
this.dropFrame ? ';' : ':',
frames<10 ? '0' : '',
frames.toString(),
String(frames).padStart(String(Math.round(this.frameRate)).length,'0'),
field
);
};
Expand Down
8 changes: 8 additions & 0 deletions test/smpte-timecode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,12 @@ describe('Issues', function() {
var t1 = new Timecode("10:00:00;06", 23.976);
expect(t1.dropFrame).to.be(false);
});


it ('#37 Time Codes >100', function(){
var t = new Timecode("00:00:10;112", 200, false);
expect(t.dropFrame).to.be(false);
expect(t.frameCount).to.be(2112);
expect(Timecode('12:34:56:578',600).toString()).to.be('12:34:56:578');
});
});

0 comments on commit 25db286

Please sign in to comment.