mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-1213: Move date/time parsing code to own functions.
This commit is contained in:
@@ -48,9 +48,26 @@ angular.module('form').controller('dateFieldController', ['$scope', '$injector',
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the date components of the given string into a Date with only the
|
||||||
|
* date components set. The resulting Date will be in the UTC timezone,
|
||||||
|
* with the time left as midnight. The input string must be in the format
|
||||||
|
* YYYY-MM-DD (zero-padded).
|
||||||
|
*
|
||||||
|
* @param {String} str
|
||||||
|
* The date string to parse.
|
||||||
|
*
|
||||||
|
* @returns {Date}
|
||||||
|
* A Date object, in the UTC timezone, with only the date components
|
||||||
|
* set.
|
||||||
|
*/
|
||||||
|
var parseDate = function parseDate(str) {
|
||||||
|
return new Date(str + 'T00:00Z');
|
||||||
|
};
|
||||||
|
|
||||||
// Update typed value when model is changed
|
// Update typed value when model is changed
|
||||||
$scope.$watch('model', function modelChanged(model) {
|
$scope.$watch('model', function modelChanged(model) {
|
||||||
$scope.typedValue = (model ? new Date(model + 'T00:00Z') : null);
|
$scope.typedValue = (model ? parseDate(model) : null);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update string value in model when typed value is changed
|
// Update string value in model when typed value is changed
|
||||||
|
@@ -48,9 +48,26 @@ angular.module('form').controller('timeFieldController', ['$scope', '$injector',
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the time components of the given string into a Date with only the
|
||||||
|
* time components set. The resulting Date will be in the UTC timezone,
|
||||||
|
* with the date left as 1970-01-01. The input string must be in the format
|
||||||
|
* HH:MM:SS (zero-padded, 24-hour).
|
||||||
|
*
|
||||||
|
* @param {String} str
|
||||||
|
* The time string to parse.
|
||||||
|
*
|
||||||
|
* @returns {Date}
|
||||||
|
* A Date object, in the UTC timezone, with only the time components
|
||||||
|
* set.
|
||||||
|
*/
|
||||||
|
var parseTime = function parseTime(str) {
|
||||||
|
return new Date('1970-01-01T' + str + 'Z');
|
||||||
|
};
|
||||||
|
|
||||||
// Update typed value when model is changed
|
// Update typed value when model is changed
|
||||||
$scope.$watch('model', function modelChanged(model) {
|
$scope.$watch('model', function modelChanged(model) {
|
||||||
$scope.typedValue = (model ? new Date('1970-01-01T' + model + 'Z') : null);
|
$scope.typedValue = (model ? parseTime(model) : null);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update string value in model when typed value is changed
|
// Update string value in model when typed value is changed
|
||||||
|
Reference in New Issue
Block a user