Skip to content

Commit

Permalink
Merge pull request #118 from slifty/117-timestampfix
Browse files Browse the repository at this point in the history
Support longer times
  • Loading branch information
goatandsheep authored May 12, 2022
2 parents 71ad68e + 4c60714 commit b9f1702
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function ParserError (message, error) {

ParserError.prototype = Object.create(Error.prototype);

const TIMESTAMP_REGEXP = /([0-9]{1,2})?:?([0-9]{2}):([0-9]{2}\.[0-9]{2,3})/;
const TIMESTAMP_REGEXP = /([0-9]+)?:?([0-9]{2}):([0-9]{2}\.[0-9]{2,3})/;

function parse (input, options) {
if (!options) {
Expand Down
10 changes: 10 additions & 0 deletions test/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ a`;
parse(input).cues[0].end.should.equal(0.001);
});

it('should parse cue with long hours timestamp', () => {
const input = `WEBVTT
10000:00:00.000 --> 10000:00:00.001
a`;

parse(input).cues[0].start.should.equal(36000000);
parse(input).cues[0].end.should.equal(36000000.001);
});

it('should return parsed data about a single cue', () => {
const input = `WEBVTT
Expand Down

0 comments on commit b9f1702

Please sign in to comment.