Skip to content

Commit

Permalink
refactor: remove square brackets from time format
Browse files Browse the repository at this point in the history
  • Loading branch information
ifedapoolarewaju committed Jun 10, 2017
1 parent 140fc69 commit 623695b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions browser/js/funcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 623695b

Please sign in to comment.