[Time Conductor] Use default format

...from TelemetryFormatter, and log when a requested format
is unavailable.
This commit is contained in:
Victor Woeltjen 2015-10-30 13:17:53 -07:00
parent 6db7f056dc
commit 4f9a65a5fe
3 changed files with 15 additions and 5 deletions

View File

@ -15,6 +15,12 @@
"key": "utc",
"implementation": "UTCTimeFormat.js"
}
],
"constants": [
{
"key": "DEFAULT_TIME_FORMAT",
"value": "utc"
}
]
}
}

View File

@ -38,7 +38,7 @@
{
"key": "telemetryFormatter",
"implementation": "TelemetryFormatter.js",
"depends": [ "formatService" ]
"depends": [ "formatService", "DEFAULT_TIME_FORMAT", "$log" ]
},
{
"key": "telemetrySubscriber",

View File

@ -37,8 +37,10 @@ define(
* @memberof platform/telemetry
* @constructor
*/
function TelemetryFormatter(formatService) {
function TelemetryFormatter(formatService, defaultFormatKey, $log) {
this.formatService = formatService;
this.defaultFormat = formatService.getFormat(defaultFormatKey);
this.$log = $log;
}
/**
@ -51,9 +53,11 @@ define(
* data and time, suitable for display.
*/
TelemetryFormatter.prototype.formatDomainValue = function (v, key) {
var formatter = this.formatService.getFormat(key) ||
this.formatService.getFormat('utc');
return isNaN(v) ? "" : formatter.format(v);
var formatter = (key === undefined) ?
this.defaultFormat :
this.formatService.getFormat(key);
return isNaN(v) ? "" : formatter ? formatter.format(v) : String(v);
};
/**