Fixed rus/eng premiere date
This commit is contained in:
parent
eeaf0056a4
commit
af8b923dfc
1 changed files with 55 additions and 3 deletions
|
@ -765,10 +765,10 @@ if (Math.ceil(os.freemem()) < 50) {
|
|||
}
|
||||
if (movie['premiere']) {
|
||||
if (
|
||||
/[0-9]{1,2}\s+[а-я]*\s+[0-9]{4}/i.test(movie['premiere'])
|
||||
/[0-9]{1,2}\s+[а-я]+\s+[0-9]{4}/i.test(movie['premiere'])
|
||||
) {
|
||||
var p = movie['premiere'].replace(
|
||||
/([0-9]{1,2})\s+([а-я]*)\s+([0-9]{4})/i,
|
||||
/([0-9]{1,2})\s+([а-я]+)\s+([0-9]{4})/i,
|
||||
'$3-$2-$1'
|
||||
);
|
||||
[
|
||||
|
@ -785,10 +785,62 @@ if (Math.ceil(os.freemem()) < 50) {
|
|||
'ноября',
|
||||
'декабря'
|
||||
].forEach(function(month, i) {
|
||||
p = p.replace(month, i + 1 + '');
|
||||
if (p.toLowerCase().indexOf(month) + 1) {
|
||||
p = p.toLowerCase().replace(month, i + 1 + '');
|
||||
}
|
||||
});
|
||||
p = p
|
||||
.split('-')
|
||||
.map(function(num) {
|
||||
if (num && parseInt(num) < 10) {
|
||||
num = '0' + num;
|
||||
}
|
||||
return num;
|
||||
})
|
||||
.join('-');
|
||||
movie['premiere'] = p;
|
||||
}
|
||||
if (
|
||||
/[0-9]{1,2}\s+[a-z]+\s+[0-9]{4}/i.test(movie['premiere'])
|
||||
) {
|
||||
var pp = movie['premiere'].replace(
|
||||
/([0-9]{1,2})\s+([a-z]+)\s+([0-9]{4})/i,
|
||||
'$3-$2-$1'
|
||||
);
|
||||
[
|
||||
'JAN',
|
||||
'FEB',
|
||||
'MAR',
|
||||
'APR',
|
||||
'MAY',
|
||||
'JUN',
|
||||
'JUL',
|
||||
'AUG',
|
||||
'SEP',
|
||||
'OCT',
|
||||
'NOV',
|
||||
'DEC'
|
||||
].forEach(function(month, i) {
|
||||
if (pp.toUpperCase().indexOf(month) + 1) {
|
||||
p = p.toUpperCase().replace(month, i + 1 + '');
|
||||
}
|
||||
});
|
||||
p = p
|
||||
.split('-')
|
||||
.map(function(num) {
|
||||
if (num && parseInt(num) < 10) {
|
||||
num = '0' + num;
|
||||
}
|
||||
return num;
|
||||
})
|
||||
.join('-');
|
||||
movie['premiere'] = p;
|
||||
}
|
||||
if (
|
||||
/[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}/i.test(movie['premiere'])
|
||||
) {
|
||||
movie['premiere'] = movie['premiere'] + 'T00:00:00.000Z';
|
||||
}
|
||||
var year = new Date(movie['premiere']).getFullYear();
|
||||
if (!movie['year']) {
|
||||
movie['year'] = !isNaN(year) ? year + '' : '0';
|
||||
|
|
Loading…
Reference in a new issue