Skip to content

Commit 25db286

Browse files
committed
fixes #38 support for higher framerates
1 parent 09812ef commit 25db286

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

smpte-timecode.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
}
6363
else if (typeof timeCode === 'string') {
6464
// pick it apart
65-
var parts = timeCode.match('^([012]\\d):(\\d\\d):(\\d\\d)(:|;|\\.)(\\d\\d)$');
65+
var parts = timeCode.match('^([012]\\d):(\\d\\d):(\\d\\d)(:|;|\\.)(\\d+)$');
6666
if (!parts) throw new Error("Timecode string expected as HH:MM:SS:FF or HH:MM:SS;FF");
6767
this.hours = parseInt(parts[1]);
6868
this.minutes = parseInt(parts[2]);
@@ -180,17 +180,13 @@
180180
else throw new Error('Unsupported string format');
181181
}
182182
return "".concat(
183-
this.hours<10 ? '0' : '',
184-
this.hours.toString(),
183+
String(this.hours).padStart(2,'0'),
185184
':',
186-
this.minutes<10 ? '0' : '',
187-
this.minutes.toString(),
185+
String(this.minutes).padStart(2,'0'),
188186
':',
189-
this.seconds<10 ? '0' : '',
190-
this.seconds.toString(),
187+
String(this.seconds).padStart(2,'0'),
191188
this.dropFrame ? ';' : ':',
192-
frames<10 ? '0' : '',
193-
frames.toString(),
189+
String(frames).padStart(String(Math.round(this.frameRate)).length,'0'),
194190
field
195191
);
196192
};

test/smpte-timecode-test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,12 @@ describe('Issues', function() {
284284
var t1 = new Timecode("10:00:00;06", 23.976);
285285
expect(t1.dropFrame).to.be(false);
286286
});
287+
288+
289+
it ('#37 Time Codes >100', function(){
290+
var t = new Timecode("00:00:10;112", 200, false);
291+
expect(t.dropFrame).to.be(false);
292+
expect(t.frameCount).to.be(2112);
293+
expect(Timecode('12:34:56:578',600).toString()).to.be('12:34:56:578');
294+
});
287295
});

0 commit comments

Comments
 (0)