mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 15:43:48 +00:00
[Time Conductor] Use formatService instead of timeService
This commit is contained in:
@ -53,7 +53,7 @@
|
|||||||
{
|
{
|
||||||
"key": "TimeRangeController",
|
"key": "TimeRangeController",
|
||||||
"implementation": "controllers/TimeRangeController.js",
|
"implementation": "controllers/TimeRangeController.js",
|
||||||
"depends": [ "$scope", "timeService" ]
|
"depends": [ "$scope", "formatService", "now" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "DateTimePickerController",
|
"key": "DateTimePickerController",
|
||||||
|
@ -26,7 +26,7 @@ define(
|
|||||||
function (moment) {
|
function (moment) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var DATE_FORMAT = "YYYY-MM-DD HH:mm:ss",
|
var DEFAULT_FORMAT = "utc",
|
||||||
TICK_SPACING_PX = 150;
|
TICK_SPACING_PX = 150;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,20 +34,20 @@ define(
|
|||||||
* @memberof platform/commonUI/general
|
* @memberof platform/commonUI/general
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function TimeRangeController($scope, timeService) {
|
function TimeRangeController($scope, formatService, now) {
|
||||||
var tickCount = 2,
|
var tickCount = 2,
|
||||||
innerMinimumSpan = 1000, // 1 second
|
innerMinimumSpan = 1000, // 1 second
|
||||||
outerMinimumSpan = 1000 * 60 * 60, // 1 hour
|
outerMinimumSpan = 1000 * 60 * 60, // 1 hour
|
||||||
initialDragValue,
|
initialDragValue,
|
||||||
timeSystem = timeService.system(); // Start with default
|
formatter = formatService.getFormat(DEFAULT_FORMAT);
|
||||||
|
|
||||||
function formatTimestamp(ts) {
|
function formatTimestamp(ts) {
|
||||||
return timeSystem.format(ts);
|
return formatter.format(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseTimestamp(text) {
|
function parseTimestamp(text) {
|
||||||
if (timeSystem.validate(text)) {
|
if (formatter.validate(text)) {
|
||||||
return timeSystem.parse(text);
|
return formatter.parse(text);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Could not parse " + text);
|
throw new Error("Could not parse " + text);
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function defaultBounds() {
|
function defaultBounds() {
|
||||||
var t = timeSystem.now();
|
var t = now();
|
||||||
return {
|
return {
|
||||||
start: t - 24 * 3600 * 1000, // One day
|
start: t - 24 * 3600 * 1000, // One day
|
||||||
end: t
|
end: t
|
||||||
@ -278,17 +278,9 @@ define(
|
|||||||
updateViewFromModel($scope.ngModel);
|
updateViewFromModel($scope.ngModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTimeSystem(key) {
|
function updateFormat(key) {
|
||||||
timeSystem = timeService.system(key) || timeService.system();
|
formatter = formatService.getFormat(key) ||
|
||||||
|
formatService.getFormat(DEFAULT_FORMAT);
|
||||||
// One second / one hour in UTC; should be
|
|
||||||
// similarly useful in other time systems.
|
|
||||||
innerMinimumSpan = timeSystem.increment(-3);
|
|
||||||
outerMinimumSpan = timeSystem.increment(-1);
|
|
||||||
reinitializeBounds(
|
|
||||||
timeSystem.now(),
|
|
||||||
timeSystem.increment()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateStartFromPicker(value) {
|
function updateStartFromPicker(value) {
|
||||||
@ -321,7 +313,7 @@ define(
|
|||||||
$scope.$watch("ngModel.outer.end", updateEndFromPicker);
|
$scope.$watch("ngModel.outer.end", updateEndFromPicker);
|
||||||
$scope.$watch("boundsModel.start", updateStartFromText);
|
$scope.$watch("boundsModel.start", updateStartFromText);
|
||||||
$scope.$watch("boundsModel.end", updateEndFromText);
|
$scope.$watch("boundsModel.end", updateEndFromText);
|
||||||
$scope.$watch("parameters.system", updateTimeSystem);
|
$scope.$watch("parameters.format", updateFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TimeRangeController;
|
return TimeRangeController;
|
||||||
|
Reference in New Issue
Block a user