diff --git a/platform/commonUI/general/src/controllers/TimeRangeController.js b/platform/commonUI/general/src/controllers/TimeRangeController.js
index f603ec2ccc..3e792af052 100644
--- a/platform/commonUI/general/src/controllers/TimeRangeController.js
+++ b/platform/commonUI/general/src/controllers/TimeRangeController.js
@@ -40,11 +40,6 @@ define(
return moment.utc(ts).format(DATE_FORMAT);
}
- function parseTimestamp(text, fallback) {
- var m = moment.utc(text, DATE_FORMAT);
- return m.isValid() ? m.valueOf() : fallback;
- }
-
// From 0.0-1.0 to "0%"-"1%"
function toPercent(p) {
return (100 * p) + "%";
@@ -103,8 +98,8 @@ define(
ngModel.inner = ngModel.inner || copyBounds(ngModel.outer);
// First, dates for the date pickers for outer bounds
- $scope.startOuterDate = formatTimestamp(ngModel.outer.start);
- $scope.endOuterDate = formatTimestamp(ngModel.outer.end);
+ $scope.startOuterDate = new Date(ngModel.outer.start);
+ $scope.endOuterDate = new Date(ngModel.outer.end);
// Then various updates for the inner span
updateViewForInnerSpanFromModel(ngModel);
@@ -177,10 +172,10 @@ define(
updateViewFromModel($scope.ngModel);
}
- function updateOuterStart(text) {
+ function updateOuterStart(date) {
var ngModel = $scope.ngModel;
ngModel.outer.start =
- parseTimestamp(text, ngModel.outer.start);
+ date.getTime();
ngModel.outer.end =
Math.max(ngModel.outer.start, ngModel.outer.end);
ngModel.inner.start =
@@ -190,10 +185,10 @@ define(
updateViewForInnerSpanFromModel(ngModel);
}
- function updateOuterEnd(text) {
+ function updateOuterEnd(date) {
var ngModel = $scope.ngModel;
ngModel.outer.end =
- parseTimestamp(text, ngModel.outer.end);
+ date.getTime();
ngModel.outer.start =
Math.min(ngModel.outer.end, ngModel.outer.start);
ngModel.inner.start =
diff --git a/platform/commonUI/general/test/controllers/TimeRangeControllerSpec.js b/platform/commonUI/general/test/controllers/TimeRangeControllerSpec.js
new file mode 100644
index 0000000000..48411756b0
--- /dev/null
+++ b/platform/commonUI/general/test/controllers/TimeRangeControllerSpec.js
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Open MCT Web, Copyright (c) 2014-2015, United States Government
+ * as represented by the Administrator of the National Aeronautics and Space
+ * Administration. All rights reserved.
+ *
+ * Open MCT Web is licensed under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * Open MCT Web includes source code licensed under additional open source
+ * licenses. See the Open Source Licenses file (LICENSES.md) included with
+ * this source code distribution or the Licensing information page available
+ * at runtime from the About dialog for additional information.
+ *****************************************************************************/
+/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
+
+define(
+ ["../../src/controllers/TimeRangeController"],
+ function (TimeRangeController) {
+ "use strict";
+
+ describe("The TimeRangeController", function () {
+ var mockScope,
+ mockNow,
+ controller;
+
+ function fireWatch(expr, value) {
+ mockScope.$watch.calls.forEach(function (call) {
+ if (call.args[0] === expr) {
+ call.args[1](value);
+ }
+ });
+ }
+
+ function fireWatchCollection(expr, value) {
+ mockScope.$watchCollection.calls.forEach(function (call) {
+ if (call.args[0] === expr) {
+ call.args[1](value);
+ }
+ });
+ }
+
+ beforeEach(function () {
+ mockScope = jasmine.createSpyObj(
+ "$scope",
+ [ "$apply", "$watch", "$watchCollection" ]
+ );
+ mockNow = jasmine.createSpy('now');
+ controller = new TimeRangeController(mockScope, mockNow);
+ });
+
+ it("watches the model that was passed in", function () {
+ expect(mockScope.$watchCollection)
+ .toHaveBeenCalledWith("ngModel", jasmine.any(Function));
+ });
+
+
+ });
+ }
+);
diff --git a/platform/commonUI/general/test/suite.json b/platform/commonUI/general/test/suite.json
index 37fc4c4b78..38f8a447ee 100644
--- a/platform/commonUI/general/test/suite.json
+++ b/platform/commonUI/general/test/suite.json
@@ -6,6 +6,7 @@
"controllers/GetterSetterController",
"controllers/SelectorController",
"controllers/SplitPaneController",
+ "controllers/TimeRangeController",
"controllers/ToggleController",
"controllers/TreeNodeController",
"controllers/ViewSwitcherController",
@@ -15,4 +16,4 @@
"directives/MCTScroll",
"services/UrlService",
"StyleSheetLoader"
-]
\ No newline at end of file
+]