parse more date formats

This commit is contained in:
j 2019-04-02 11:07:26 +08:00
parent b7bc3005b2
commit a9647e0015

View file

@ -609,6 +609,20 @@ pandora.ui.infoView = function(data, isMixed) {
$('<div>').css({height: '16px'}).appendTo($statistics); $('<div>').css({height: '16px'}).appendTo($statistics);
function cleanupDate(value) {
if (/\d{2}-\d{2}-\d{4}/.test(value)) {
value = Ox.reverse(value.split('-')).join('-')
}
if (/\d{4}/\d{2}/\d{d}/.test(value)) {
value = value.split('/').join('-')
}
if (/\d{2}/\d{2}/\d{4}/.test(value)) {
value = Ox.reverse(value.split('/')).join('-')
}
return value
}
function editMetadata(key, value) { function editMetadata(key, value) {
if (value != data[key]) { if (value != data[key]) {
var edit = {id: isMultiple ? ui.listSelection : data.id}; var edit = {id: isMultiple ? ui.listSelection : data.id};
@ -632,9 +646,7 @@ pandora.ui.infoView = function(data, isMixed) {
} else if (key == 'imdbId') { } else if (key == 'imdbId') {
edit[key] = value.match(/\d{7}/)[0]; edit[key] = value.match(/\d{7}/)[0];
} else if (key == 'dateofcensorcertificate') { } else if (key == 'dateofcensorcertificate') {
if (/\d{2}-\d{2}-\d{4}/.test(value)) { value = cleanupDate(value);
value = Ox.reverse(value.split('-')).join('-')
}
edit[key] = value; edit[key] = value;
} else { } else {
edit[key] = value; edit[key] = value;
@ -733,9 +745,7 @@ pandora.ui.infoView = function(data, isMixed) {
if (key == 'year') { if (key == 'year') {
ret = formatLink(value, 'year'); ret = formatLink(value, 'year');
} else if (['releasedate', 'dateofcensorcertificate'].indexOf(key) > -1) { } else if (['releasedate', 'dateofcensorcertificate'].indexOf(key) > -1) {
if (/\d{2}-\d{2}-\d{4}/.test(value)) { value = cleanupDate(value);
value = Ox.reverse(value.split('-')).join('-')
}
ret = value ? Ox.formatDate(value, ret = value ? Ox.formatDate(value,
['', '%Y', '%B %Y', '%B %e, %Y'][value.split('-').length], ['', '%Y', '%B %Y', '%B %e, %Y'][value.split('-').length],
true true