From 3fe386fcd60e8f9a221c5cdb41487d10ef1c1c9e Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 27 Oct 2015 11:21:44 -0700 Subject: [PATCH] [Time Conductor] Use formatService from telemetryFormatter --- platform/telemetry/bundle.json | 5 +++-- platform/telemetry/src/TelemetryFormatter.js | 21 ++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/platform/telemetry/bundle.json b/platform/telemetry/bundle.json index 69b32b54c7..79cf4d503a 100644 --- a/platform/telemetry/bundle.json +++ b/platform/telemetry/bundle.json @@ -37,7 +37,8 @@ "services": [ { "key": "telemetryFormatter", - "implementation": "TelemetryFormatter.js" + "implementation": "TelemetryFormatter.js", + "depends": [ "formatService" ] }, { "key": "telemetrySubscriber", @@ -63,4 +64,4 @@ } ] } -} \ No newline at end of file +} diff --git a/platform/telemetry/src/TelemetryFormatter.js b/platform/telemetry/src/TelemetryFormatter.js index bbd4cf100c..125d92710c 100644 --- a/platform/telemetry/src/TelemetryFormatter.js +++ b/platform/telemetry/src/TelemetryFormatter.js @@ -22,14 +22,13 @@ /*global define,moment*/ define( - ['moment'], - function (moment) { + [], + function () { "use strict"; // Date format to use for domain values; in particular, // use day-of-year instead of month/day - var DATE_FORMAT = "YYYY-DDD HH:mm:ss", - VALUE_FORMAT_DIGITS = 3; + var VALUE_FORMAT_DIGITS = 3; /** * The TelemetryFormatter is responsible for formatting (as text @@ -38,21 +37,23 @@ define( * @memberof platform/telemetry * @constructor */ - function TelemetryFormatter() { + function TelemetryFormatter(formatService) { + this.formatService = formatService; } /** * Format a domain value. - * @param {number} v the domain value; a timestamp + * @param {number} v the domain value; usually, a timestamp * in milliseconds since start of 1970 - * @param {string} [key] the key which identifies the - * domain; if unspecified or unknown, this will - * be treated as a standard timestamp. + * @param {string} [key] a key which identifies the format + * to use * @returns {string} a textual representation of the * data and time, suitable for display. */ TelemetryFormatter.prototype.formatDomainValue = function (v, key) { - return isNaN(v) ? "" : moment.utc(v).format(DATE_FORMAT); + var formatter = this.formatService.getFormat(key) || + this.formatService.getFormat('utc'); + return isNaN(v) ? "" : formatter.format(v); }; /**