From 618f4e1474bc0ad88230cf2604d2a946aba2f0bf Mon Sep 17 00:00:00 2001 From: Brandon Kobel Date: Wed, 17 Jan 2018 10:38:53 -0500 Subject: [PATCH] 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 --- package.json | 2 +- .../kibana/public/discover/controllers/discover.js | 2 +- src/ui/public/directives/pretty_duration.js | 2 +- src/ui/public/timefilter/timefilter.js | 2 +- src/ui/public/timepicker/timepicker.js | 6 +++--- yarn.lock | 11 +++++------ 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 6253d6c9b3ec..47e220276840 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/core_plugins/kibana/public/discover/controllers/discover.js b/src/core_plugins/kibana/public/discover/controllers/discover.js index 1bc79cda04e1..6902f6c04f28 100644 --- a/src/core_plugins/kibana/public/discover/controllers/discover.js +++ b/src/core_plugins/kibana/public/discover/controllers/discover.js @@ -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 }) }; }; diff --git a/src/ui/public/directives/pretty_duration.js b/src/ui/public/directives/pretty_duration.js index 25fb4763a928..0f9dea060ab3 100644 --- a/src/ui/public/directives/pretty_duration.js +++ b/src/ui/public/directives/pretty_duration.js @@ -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]; } } diff --git a/src/ui/public/timefilter/timefilter.js b/src/ui/public/timefilter/timefilter.js index 0e804066c90b..1f038f523949 100644 --- a/src/ui/public/timefilter/timefilter.js +++ b/src/ui/public/timefilter/timefilter.js @@ -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 }) }; }; diff --git a/src/ui/public/timepicker/timepicker.js b/src/ui/public/timepicker/timepicker.js index 06ba13b7aa78..659f1b888f94 100644 --- a/src/ui/public/timepicker/timepicker.js +++ b/src/ui/public/timepicker/timepicker.js @@ -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'; diff --git a/yarn.lock b/yarn.lock index 9c606cf2fe6c..d4a4dc0a9864 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"