fix(TTML): Fix timing parsing when using 1dp (#6830)

Fixes #6829
This commit is contained in:
David HM Morgan
2024-06-14 20:30:01 +01:00
committed by GitHub
parent 601098bad1
commit 3783ffd44b
2 changed files with 14 additions and 2 deletions
+2 -2
View File
@@ -1336,10 +1336,10 @@ shaka.text.TtmlTextParser.timeColonFormat_ = /^(?:(\d{2,}):)?(\d{2}):(\d{2})$/;
/**
* @const
* @private {!RegExp}
* @example 01:02:43.0345555 or 02:43.03
* @example 01:02:43.0345555 or 02:43.03 or 02:45.5
*/
shaka.text.TtmlTextParser.timeColonFormatMilliseconds_ =
/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d{2,})$/;
/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/;
/**
* @const
+12
View File
@@ -358,6 +358,18 @@ describe('TtmlTextParser', () => {
{startTime: 62.05, endTime: 3723.2});
});
it('supports colon formatted time with 0 or 1 dp', () => {
verifyHelper(
[
{startTime: 62, endTime: 3723.2, payload: 'Test'},
],
'<tt><body><div>' +
'<p begin="01:02" end="01:02:03.2">Test</p>' +
'</div></body></tt>',
{periodStart: 0, segmentStart: 60, segmentEnd: 3730, vttOffset: 0},
{startTime: 62, endTime: 3723.2});
});
it('accounts for offset', () => {
verifyHelper(
[