mirror of
https://github.com/nasa/openmct.git
synced 2025-06-13 12:48:14 +00:00
[Forms] Get date-time as UNIX timestamp
Get date-time as a UNIX timestamp (in milliseconds since start of 1970) add the model level for date-time controls. WTD-530.
This commit is contained in:
@ -1,23 +1,26 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
[],
|
||||
["../../lib/moment.min"],
|
||||
function () {
|
||||
|
||||
var DATE_FORMAT = "YYYY-DDD";
|
||||
|
||||
function DateTimeController($scope) {
|
||||
|
||||
function update() {
|
||||
var date = $scope.datetime.date,
|
||||
hour = $scope.datetime.hour,
|
||||
min = $scope.datetime.min,
|
||||
sec = $scope.datetime.sec;
|
||||
sec = $scope.datetime.sec,
|
||||
fullDateTime = moment.utc(date, DATE_FORMAT)
|
||||
.hour(hour || 0)
|
||||
.minute(min || 0)
|
||||
.second(sec || 0);
|
||||
|
||||
$scope.ngModel[$scope.field] = [
|
||||
date,
|
||||
hour,
|
||||
min,
|
||||
sec
|
||||
].join(".");
|
||||
if (fullDateTime.isValid()) {
|
||||
$scope.ngModel[$scope.field] = fullDateTime.valueOf();
|
||||
}
|
||||
}
|
||||
|
||||
$scope.$watch("datetime.date", update);
|
||||
|
Reference in New Issue
Block a user