Upgrading the datemath.parse syntax to version 4.0 (#15999) (#16094)

* Upgrading the datemath.parse syntax to version 4.0

* [@elastic/datemath] bump to version 4

* Updating yarn.lock for datemath-js@4.0

* Updating to dateamath-js@4.0.1
This commit is contained in:
Brandon Kobel 2018-01-17 10:38:53 -05:00 committed by GitHub
parent 77c4f107bf
commit 618f4e1474
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 13 deletions

View file

@ -73,7 +73,7 @@
"url": "https://github.com/elastic/kibana.git"
},
"dependencies": {
"@elastic/datemath": "2.3.0",
"@elastic/datemath": "4.0.1",
"@elastic/eui": "0.0.13",
"@elastic/filesaver": "1.1.2",
"@elastic/numeral": "2.3.0",

View file

@ -581,7 +581,7 @@ function discoverController(
$scope.updateTime = function () {
$scope.timeRange = {
from: dateMath.parse(timefilter.time.from),
to: dateMath.parse(timefilter.time.to, true)
to: dateMath.parse(timefilter.time.to, { roundUp: true })
};
};

View file

@ -62,7 +62,7 @@ module.directive('prettyDuration', function (config, timeUnits) {
if ($scope[time] === 'now') {
display[time] = 'now';
} else {
const tryParse = dateMath.parse($scope[time], time === 'to' ? true : false);
const tryParse = dateMath.parse($scope[time], { roundUp: time === 'to' });
display[time] = moment.isMoment(tryParse) ? '~ ' + tryParse.fromNow() : $scope[time];
}
}

View file

@ -104,7 +104,7 @@ uiModules
Timefilter.prototype.getBounds = function () {
return {
min: dateMath.parse(this.time.from),
max: dateMath.parse(this.time.to, true)
max: dateMath.parse(this.time.to, { roundUp: true })
};
};

View file

@ -134,7 +134,7 @@ module.directive('kbnTimepicker', function (timeUnits, refreshIntervals) {
break;
case 'absolute':
$scope.absolute.from = dateMath.parse($scope.from || moment().subtract(15, 'minutes'));
$scope.absolute.to = dateMath.parse($scope.to || moment(), true);
$scope.absolute.to = dateMath.parse($scope.to || moment(), { roundUp: true });
break;
}
@ -158,7 +158,7 @@ module.directive('kbnTimepicker', function (timeUnits, refreshIntervals) {
$scope.checkRelative = function () {
if ($scope.relative.from.count != null && $scope.relative.to.count != null) {
const from = dateMath.parse(getRelativeString('from'));
const to = dateMath.parse(getRelativeString('to'), true);
const to = dateMath.parse(getRelativeString('to'), { roundUp: true });
if (to && from) return to.isBefore(from);
return true;
}
@ -166,7 +166,7 @@ module.directive('kbnTimepicker', function (timeUnits, refreshIntervals) {
$scope.formatRelative = function (key) {
const relativeString = getRelativeString(key);
const parsed = dateMath.parse(relativeString, key === 'to');
const parsed = dateMath.parse(relativeString, { roundUp: key === 'to' });
let preview;
if (relativeString === 'now') {
preview = 'Now';

View file

@ -63,12 +63,11 @@
lodash "^4.2.0"
to-fast-properties "^2.0.0"
"@elastic/datemath@2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@elastic/datemath/-/datemath-2.3.0.tgz#d540cc7660f0b7a1e50277a7af3a2fef18297ef7"
"@elastic/datemath@4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@elastic/datemath/-/datemath-4.0.1.tgz#d0d50d675f42a881912e1d5ca84bda493bb7e92d"
dependencies:
lodash "~3.10.1"
moment "~2.13.0"
moment "^2.13.0"
"@elastic/eslint-config-kibana@0.15.0":
version "0.15.0"
@ -7827,7 +7826,7 @@ moment-timezone@0.5.4:
dependencies:
moment ">= 2.6.0"
moment@2.13.0, moment@2.x.x, "moment@>= 2.6.0", moment@^2.10.3, moment@^2.10.6, moment@^2.7.0, moment@~2.13.0:
moment@2.13.0, moment@2.x.x, "moment@>= 2.6.0", moment@^2.10.3, moment@^2.10.6, moment@^2.13.0, moment@^2.7.0:
version "2.13.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.13.0.tgz#24162d99521e6d40f99ae6939e806d2139eaac52"