mirror of
https://github.com/nasa/openmct.git
synced 2025-02-18 16:40:58 +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:
parent
a464fee6df
commit
aaa0ff768d
6
platform/forms/lib/moment.min.js
vendored
Normal file
6
platform/forms/lib/moment.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -23,6 +23,10 @@
|
||||
<input type='text'
|
||||
name='hour'
|
||||
maxlength='2'
|
||||
min='0'
|
||||
max='23'
|
||||
integer
|
||||
ng-pattern='/\d+/'
|
||||
ng-model="datetime.hour"
|
||||
ng-required='true'/>
|
||||
</span>
|
||||
@ -30,6 +34,10 @@
|
||||
<input type='text'
|
||||
name='min'
|
||||
maxlength='2'
|
||||
min='0'
|
||||
max='59'
|
||||
integer
|
||||
ng-pattern='/\d+/'
|
||||
ng-model="datetime.min"
|
||||
ng-required='true'/>
|
||||
</span>
|
||||
@ -37,6 +45,10 @@
|
||||
<input type='text'
|
||||
name='sec'
|
||||
maxlength='2'
|
||||
min='0'
|
||||
max='59'
|
||||
integer
|
||||
ng-pattern='/\d+/'
|
||||
ng-model="datetime.sec"
|
||||
ng-required='true'/>
|
||||
</span>
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user