add Ox.formatSRT

This commit is contained in:
rlx 2014-09-18 16:42:19 +02:00
parent 13a339d924
commit ceca50ae59

View file

@ -740,6 +740,21 @@ Ox.formatRoman = function(number) {
return string;
};
/*@
Ox.formatSRT <f> Formats subtitles as SRT
@*/
Ox.formatSRT = function(subtitles) {
return Ox.sortBy(subtitles, ['in', 'out']).map(function(subtitle, index) {
return [
index + 1,
['in', 'out'].map(function(key) {
return Ox.formatDuration(subtitle[key]).replace('.', ',');
}).join(' --> '),
subtitle['text']
].join('\n')
}).join('\n\n');
};
/*@
Ox.formatString <f> Basic string formatting
> Ox.formatString('{0}{1}', ['foo', 'bar'])