From a9647e0015f48f4e39b660659b5268fd7ceb8652 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 2 Apr 2019 11:07:26 +0800 Subject: [PATCH] parse more date formats --- static/js/infoView.indiancinema.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/static/js/infoView.indiancinema.js b/static/js/infoView.indiancinema.js index 3b8ede318..6b090c8ae 100644 --- a/static/js/infoView.indiancinema.js +++ b/static/js/infoView.indiancinema.js @@ -609,6 +609,20 @@ pandora.ui.infoView = function(data, isMixed) { $('
').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) { if (value != data[key]) { var edit = {id: isMultiple ? ui.listSelection : data.id}; @@ -632,9 +646,7 @@ pandora.ui.infoView = function(data, isMixed) { } else if (key == 'imdbId') { edit[key] = value.match(/\d{7}/)[0]; } else if (key == 'dateofcensorcertificate') { - if (/\d{2}-\d{2}-\d{4}/.test(value)) { - value = Ox.reverse(value.split('-')).join('-') - } + value = cleanupDate(value); edit[key] = value; } else { edit[key] = value; @@ -733,9 +745,7 @@ pandora.ui.infoView = function(data, isMixed) { if (key == 'year') { ret = formatLink(value, 'year'); } else if (['releasedate', 'dateofcensorcertificate'].indexOf(key) > -1) { - if (/\d{2}-\d{2}-\d{4}/.test(value)) { - value = Ox.reverse(value.split('-')).join('-') - } + value = cleanupDate(value); ret = value ? Ox.formatDate(value, ['', '%Y', '%B %Y', '%B %e, %Y'][value.split('-').length], true