diff options
author | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-12-01 01:13:55 +0300 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-12-19 01:15:18 +0300 |
commit | 95ddfc9341ce39ec4c301726fbc298a87f552657 (patch) | |
tree | f38f12ef7b2e45352590d4a2311ad400c5a30a7a /app | |
parent | 51a9797daa868976f6821273f61939a13a8d233a (diff) |
cleaned up date_time_formatters
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/monitoring/utils/date_time_formatters.js | 25 |
1 files 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); } |