[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:
Victor Woeltjen
2014-11-28 13:35:24 -08:00
parent a464fee6df
commit aaa0ff768d
3 changed files with 29 additions and 8 deletions

View File

@ -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);