From 95ddfc9341ce39ec4c301726fbc298a87f552657 Mon Sep 17 00:00:00 2001 From: Jose Ivan Vargas Date: Thu, 30 Nov 2017 16:13:55 -0600 Subject: [PATCH] cleaned up date_time_formatters --- .../monitoring/utils/date_time_formatters.js | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/monitoring/utils/date_time_formatters.js b/app/assets/javascripts/monitoring/utils/date_time_formatters.js index de4c6404a6d..48bdec1e030 100644 --- a/app/assets/javascripts/monitoring/utils/date_time_formatters.js +++ b/app/assets/javascripts/monitoring/utils/date_time_formatters.js @@ -9,33 +9,24 @@ export const timeFormat = d3.time('%-I:%M%p'); export const dateFormatWithName = d3.time('%a, %b %-d'); export const bisectDate = d3.bisector(d => d.time).left; -const formatMillisecond = d3.time('.%L'); -const formatSecond = d3.time(':%S'); -const formatMinute = d3.time('%-I:%M'); -const formatHour = d3.time('%-I %p'); -const formatDay = d3.time('%a %d'); -const formatWeek = d3.time('%b %d'); -const formatMonth = d3.time('%B'); -const formatYear = d3.time('%Y'); - export function timeScaleFormat(date) { let formatFunction; if (d3.timeSecond(date) < date) { - formatFunction = formatMillisecond; + formatFunction = d3.time('.%L'); } else if (d3.timeMinute(date) < date) { - formatFunction = formatSecond; + formatFunction = d3.time(':%S'); } else if (d3.timeHour(date) < date) { - formatFunction = formatMinute; + formatFunction = d3.time('%-I:%M'); } else if (d3.timeDay(date) < date) { - formatFunction = formatHour; + formatFunction = d3.time('%-I %p'); } else if (d3.timeWeek(date) < date) { - formatFunction = formatDay; + formatFunction = d3.time('%a %d'); } else if (d3.timeMonth(date) < date) { - formatFunction = formatWeek; + formatFunction = d3.time('%b %d'); } else if (d3.timeYear(date) < date) { - formatFunction = formatMonth; + formatFunction = d3.time('%B'); } else { - formatFunction = formatYear; + formatFunction = d3.time('%Y'); } return formatFunction(date); }