From 6d38d7be1f64234752159efd0595f20f4a97e95b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20V=C3=A9ril?= Date: Mon, 4 May 2020 13:57:20 +0200 Subject: [PATCH] Create pubUtils.getIssuedDate(publi) tool to get the date of a publication object --- layouts/partials/head_custom.html | 3 ++- static/js/createPubliUI.js | 3 +-- static/js/pubUtils.js | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 static/js/pubUtils.js diff --git a/layouts/partials/head_custom.html b/layouts/partials/head_custom.html index 1ffe2c29..28ce26cc 100644 --- a/layouts/partials/head_custom.html +++ b/layouts/partials/head_custom.html @@ -7,4 +7,5 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/static/js/createPubliUI.js b/static/js/createPubliUI.js index c5c41750..3c2d494f 100644 --- a/static/js/createPubliUI.js +++ b/static/js/createPubliUI.js @@ -50,8 +50,7 @@ function createPubliUI(publi,sets=new Map(),toolTips=false) { else { $("").text(publi["container-title"]).appendTo(journaldiv) } - var datArr = publi.issued["date-parts"][0] - var date = new Date(datArr[0], datArr[1] - 1, datArr[2]) + var date = pubUtils.getIssuedDate(publi) journaldiv.append(" ") $("").text(date.getFullYear().toString()).appendTo(journaldiv) journaldiv.append(" ") diff --git a/static/js/pubUtils.js b/static/js/pubUtils.js new file mode 100644 index 00000000..2d975996 --- /dev/null +++ b/static/js/pubUtils.js @@ -0,0 +1,6 @@ +class pubUtils{ + static getIssuedDate(publi) { + const parts=publi.issued["date-parts"][0] + return new Date(parts[0], parts[1] - 1, parts[2]) + } +} \ No newline at end of file