mirror of
https://github.com/nasa/openmct.git
synced 2025-04-07 19:34:25 +00:00
[Time Conductor] Implement date provider
Implement UTCDateProvider sufficient to pass spec.
This commit is contained in:
parent
794231143e
commit
c882b2d4c3
@ -28,6 +28,14 @@ define([
|
||||
) {
|
||||
"use strict";
|
||||
|
||||
var DATE_FORMAT = "YYYY-MM-DD HH:mm:ss",
|
||||
DATE_FORMATS = [
|
||||
DATE_FORMAT,
|
||||
"YYYY-MM-DD HH:mm:ss",
|
||||
"YYYY-MM-DD HH:mm",
|
||||
"YYYY-MM-DD"
|
||||
];
|
||||
|
||||
/**
|
||||
* Composites multiple DateService implementations such that
|
||||
* they can be used as one.
|
||||
@ -39,12 +47,17 @@ define([
|
||||
}
|
||||
|
||||
UTCDateProvider.prototype.validate = function (text, key) {
|
||||
return key === undefined && moment.utc(text, DATE_FORMATS).isValid();
|
||||
};
|
||||
|
||||
UTCDateProvider.prototype.format = function (value, key) {
|
||||
return key === undefined ?
|
||||
moment.utc(value).format(DATE_FORMAT) :
|
||||
undefined;
|
||||
};
|
||||
|
||||
UTCDateProvider.prototype.parse = function (text, key) {
|
||||
return key === undefined && moment.utc(text, DATE_FORMATS).valueOf();
|
||||
};
|
||||
|
||||
return UTCDateProvider;
|
||||
|
Loading…
x
Reference in New Issue
Block a user