From: pablozg Date: Wed, 25 Apr 2018 09:26:23 +0000 (+0200) Subject: Add syntax check and minor fixes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=588eb4e1a86d72a4e8aaee60d9266948916ca2c9;p=thirdparty%2Ftvheadend.git Add syntax check and minor fixes --- diff --git a/src/webui/static/app/epg.js b/src/webui/static/app/epg.js index 6ab139eea..1c641da65 100644 --- a/src/webui/static/app/epg.js +++ b/src/webui/static/app/epg.js @@ -506,10 +506,11 @@ tvheadend.epg = function() { if (value) { var dt = new Date(value); - if (tvheadend.date_mask.length > 1){ + if(/([%][MmsSyYdhq]+)/.test(tvheadend.date_mask)){ return tvheadend.toCustomDate(dt,tvheadend.date_mask); }else{ - return tvheadend.toCustomDate(dt,'%ddd, %MMMM %dd, %hh:%mm'); + var options = {weekday: 'short', day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false}; + return dt.toLocaleString(tvheadend.toLocaleFormat(), options); } } return ""; diff --git a/src/webui/static/app/idnode.js b/src/webui/static/app/idnode.js index fe1048a40..e9e744fbd 100644 --- a/src/webui/static/app/idnode.js +++ b/src/webui/static/app/idnode.js @@ -378,10 +378,11 @@ tvheadend.IdNodeField = function(conf) return function(v) { if (v > 0) { var dt = new Date(v * 1000); - if (tvheadend.date_mask.length > 1){ + if(/([%][MmsSyYdhq]+)/.test(tvheadend.date_mask)){ return tvheadend.toCustomDate(dt,tvheadend.date_mask); }else{ - return tvheadend.toCustomDate(dt,'%ddd %dd/%MM/%YYYY, %hh:%mm:%ss'); + var options = {weekday: 'short', day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false}; + return dt.toLocaleString(tvheadend.toLocaleFormat(), options); } } return ''; diff --git a/src/webui/static/app/tvheadend.js b/src/webui/static/app/tvheadend.js index 605065fae..372ca14bb 100644 --- a/src/webui/static/app/tvheadend.js +++ b/src/webui/static/app/tvheadend.js @@ -1384,8 +1384,9 @@ tvheadend.toCustomDate = function(date, format) //author: meizz, improvements by if(/(\%ddd)/.test(format)) format=format.replace(RegExp.$1, (date.toLocaleDateString(tvheadend.toLocaleFormat(), {weekday: 'short'}))); - for(var k in o) if(new RegExp("("+ k +")").test(format)) - format = format.replace(RegExp.$1, RegExp.$1.length==2 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); + for(var k in o) + if(new RegExp("("+ k +")").test(format)) + format = format.replace(RegExp.$1, RegExp.$1.length==2 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); return format; }