From 623695bee0bde0fa609e0ea6dc9ba03ba8faea72 Mon Sep 17 00:00:00 2001 From: Ifedapo Olarewaju Date: Sat, 10 Jun 2017 15:21:57 +0100 Subject: [PATCH] refactor: remove square brackets from time format --- browser/js/funcs.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/browser/js/funcs.js b/browser/js/funcs.js index 492d22b..7c49bc6 100644 --- a/browser/js/funcs.js +++ b/browser/js/funcs.js @@ -7,13 +7,14 @@ function format (number) { } function formatTime (time) { - var monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; - var date = new Date(time); - var hours = format(date.getHours()); - var minutes = format(date.getMinutes()); - var day = format(date.getDate()); - var month = monthNames[date.getMonth()]; - return `${day} ${month} [${hours}:${minutes}]` + const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + let date = new Date(time); + let hours = format(date.getHours()); + let minutes = format(date.getMinutes()); + let day = format(date.getDate()); + let month = MONTHS[date.getMonth()]; + return `${day}, ${month}. ${hours}:${minutes}` } function truncate (text, length) {