From 58ff14d782e940ac620794782ff5f00bca991234 Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Thu, 31 Aug 2017 16:45:22 +0200 Subject: [PATCH] Make date more IE friendly --- package.json | 2 +- src/components/date-picker/util.js | 14 +++++++++++--- src/index.js | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 6c8729d7..29eb12b6 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "dependencies": { "async-validator": "^1.7.1", - "core-js": "^2.4.1", + "core-js": "^2.5.0", "deepmerge": "^1.5.0", "popper.js": "^0.6.4", "tinycolor2": "^1.4.1" diff --git a/src/components/date-picker/util.js b/src/components/date-picker/util.js index 49326333..eb865f32 100644 --- a/src/components/date-picker/util.js +++ b/src/components/date-picker/util.js @@ -1,9 +1,17 @@ import dateUtil from '../../utils/date'; export const toDate = function(date) { - date = new Date(date); - if (isNaN(date.getTime())) return null; - return date; + let _date = new Date(date); + // IE patch start (#1422) + if (isNaN(_date.getTime()) && typeof date === 'string'){ + _date = date.split('-').map(Number); + _date[1] += 1; + _date = new Date(..._date); + } + // IE patch end + + if (isNaN(_date.getTime())) return null; + return _date; }; export const formatDate = function(date, format) { diff --git a/src/index.js b/src/index.js index 25661028..cd1b054f 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ // es6 polyfill +import 'core-js/fn/array/find'; import 'core-js/fn/array/find-index'; import Affix from './components/affix';